Last Update 2026/07/19
低スペック寄りのPCでローカルLLMを動作させた際の記録です。
LLM以外の仮想マシンなどが起動され、多少負荷がかかった状態で実行しています。
ベンチマークなどでLLMの性能を評価する内容ではありません。
LLM以外の仮想マシンなどが起動され、多少負荷がかかった状態で実行しています。
ベンチマークなどでLLMの性能を評価する内容ではありません。
検証用PC
|
OS |
Debian GNU/Linux 12 (bookworm) |
|
CPU |
Intel(R) Core(TM) i5-14400F |
|
GPU |
GeForce RTX 3060 12GB |
|
メモリ |
DDR4 PC4-25600 32GB × 4 |
|
SSD |
crucial P310 CT1000P310SSD8-JP |
構築環境 : Docker + Ollama (特別な設定などは無い状態)
検証用プロンプト
```
### 依頼内容
- コード生成
### 指示
- C言語
- コード以外の出力は不要
- 中括弧スタイルはオールマン
- テストコードも生成
- テストコードは別ファイル
- 実行用ソースファイル名 : sample_code.c
- テスト用ソースファイル名 : sample_test.c
- 標準ヘッダ以外は使用しない
- 戻り値はEXIT_SUCCESSを使用
- 関数はmain()の前で定義
### コード仕様(sample_code.c)
- コマンドラインから整数2つを取得
- [引数1]から[引数2]までをインクリメントして空白区切りで標準出力に出力
- 出力する文字列はmain()ではなく関数で生成
### コード仕様(sample_test.c)
- unity.hを使用しない
```
モデル詳細
Model
architecture phi3
parameters 14.7B
context length 16384
embedding length 5120
quantization Q4_K_M
Capabilities
completion
Parameters
stop "<|im_start|>"
stop "<|im_end|>"
stop "<|im_sep|>"
Phi-4 [実測結果一覧へ]
(1) temperature=0.15; top_p=---; top_k=--
2026-07-14
total duration: 30.266486451s
load duration: 66.460857ms
prompt eval count: 276 token(s)
prompt eval duration: 298.101653ms
prompt eval rate: 925.86 tokens/s
eval count: 967 token(s)
eval duration: 29.424502767s
eval rate: 32.86 tokens/s
コード生成結果の概要
・C言語による生成
・コード以外にコンパイル方法と使用法を出力
・コードの記述スタイルのオールマン指定を無視
・戻り値は stdlib.h の EXIT_*** を使用
・文字列生成関数
文字列生成ではなく出力
・main()
引数個数のチェック(エラー処理有)
文字列生成関数の呼び出し
・テストコードを別途生成
main()を伴うテストコード
標準出力をリダイレクトし関数の出力をキャプチャ(stdoutを`/dev/null` にリダイレクト)
文字列生成関数を呼び出してテスト実行
(1) 整数1 < 整数2
(2) 整数1 < 整数2 (1)と数値が異なる
(注) LLMの生成結果は毎回一定ではないため、結果によっては上記内容通りではないことが考えられます。
生成コードの実行結果
sample_code.c : 検証用プロンプトにて生成されたコードsample_test.c : 生成されたテストコード
$ gcc -Wall -o sample_code sample_code.c
$ gcc -Wall -o sample_test sample_test.c
sample_test.c: In function ‘test_generate_output’:
sample_test.c:34:13: warning: passing argument 1 of ‘freopen’ from incompatible pointer type [-Wincompatible-pointer-types]
34 | freopen(original_stdout, "w", stdout); // 元のstdoutに戻す
| ^~~~~~~~~~~~~~~
| |
| FILE *
In file included from sample_test.c:1:
/usr/include/stdio.h:271:46: note: expected ‘const char * restrict’ but argument is of type ‘FILE *’
271 | extern FILE *freopen (const char *__restrict __filename,
| ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
sample_test.c:36:9: warning: implicit declaration of function ‘strcmp’ [-Wimplicit-function-declaration]
36 | if (strcmp(buffer, expected_output1) == 0) {
| ^~~~~~
sample_test.c:3:1: note: include ‘<string.h>’ or provide a declaration of ‘strcmp’
2 | #include <stdlib.h>
+++ |+#include <string.h>
3 |
sample_test.c:54:13: warning: passing argument 1 of ‘freopen’ from incompatible pointer type [-Wincompatible-pointer-types]
54 | freopen(original_stdout, "w", stdout);
| ^~~~~~~~~~~~~~~
| |
| FILE *
/usr/include/stdio.h:271:46: note: expected ‘const char * restrict’ but argument is of type ‘FILE *’
271 | extern FILE *freopen (const char *__restrict __filename,
| ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
/bin/ld: /tmp/ccVZqApj.o: in function `test_generate_output':
sample_test.c:(.text+0x7c): undefined reference to `generate_output'
/bin/ld: sample_test.c:(.text+0x195): undefined reference to `generate_output'
collect2: error: ld returned 1 exit status
$ vi sample_code.c ← main()関数重複エラー解消のため条件付きコンパイル用の#ifndefマクロを追加
$ gcc -D TEST_MAIN -Wall -o sample_test sample_code.c sample_test.c
sample_test.c: In function ‘test_generate_output’:
sample_test.c:34:13: warning: passing argument 1 of ‘freopen’ from incompatible pointer type [-Wincompatible-pointer-types]
34 | freopen(original_stdout, "w", stdout); // 元のstdoutに戻す
| ^~~~~~~~~~~~~~~
| |
| FILE *
In file included from sample_test.c:1:
/usr/include/stdio.h:271:46: note: expected ‘const char * restrict’ but argument is of type ‘FILE *’
271 | extern FILE *freopen (const char *__restrict __filename,
| ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
sample_test.c:36:9: warning: implicit declaration of function ‘strcmp’ [-Wimplicit-function-declaration]
36 | if (strcmp(buffer, expected_output1) == 0) {
| ^~~~~~
sample_test.c:3:1: note: include ‘<string.h>’ or provide a declaration of ‘strcmp’
2 | #include <stdlib.h>
+++ |+#include <string.h>
3 |
sample_test.c:54:13: warning: passing argument 1 of ‘freopen’ from incompatible pointer type [-Wincompatible-pointer-types]
54 | freopen(original_stdout, "w", stdout);
| ^~~~~~~~~~~~~~~
| |
| FILE *
/usr/include/stdio.h:271:46: note: expected ‘const char * restrict’ but argument is of type ‘FILE *’
271 | extern FILE *freopen (const char *__restrict __filename,
| ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
$ ./sample_code 1 5
1 2 3 4 5 $ ./sample_code -3 3
-3 -2 -1 0 1 2 3 $ ./sample_code 1 1
1 $ ./sample_code 5 1
$ ./sample_test ← エラーは無いものの動作不良
$ vi sample_test.c ← stdoutのリダイレクト先を/dev/nullから変更など修正箇所多数
$ gcc -D TEST_MAIN -Wall -o sample_test sample_code.c sample_test.c
sample_test.c: In function ‘test_generate_output’:
sample_test.c:40:9: warning: implicit declaration of function ‘strcmp’ [-Wimplicit-function-declaration]
40 | if (strcmp(buffer, expected_output1) == 0) {
| ^~~~~~
sample_test.c:3:1: note: include ‘<string.h>’ or provide a declaration of ‘strcmp’
2 | #include <stdlib.h>
+++ |+#include <string.h>
3 |
$ ./sample_test
Test 1 passed.
Test 2 passed.
(2) temperature=0.15; top_p=0.7; top_k=--
2026-07-14
total duration: 28.089259797s
load duration: 55.630735ms
prompt eval count: 276 token(s)
prompt eval duration: 44.93004ms
prompt eval rate: 6142.88 tokens/s
eval count: 907 token(s)
eval duration: 27.547624448s
eval rate: 32.92 tokens/s
コード生成結果の概要
・C言語による生成
・コード以外にコンパイル方法と使用法を出力
・コードの記述スタイルのオールマン指定を無視
・戻り値は stdlib.h の EXIT_*** を使用
・文字列生成関数
文字列生成ではなく出力
・main()
引数個数のチェック(エラー処理有)
文字列生成関数の呼び出し
・テストコードを別途生成
main()を伴うテストコード
標準出力をリダイレクトし関数の出力をキャプチャ(stdoutを`/dev/null` にリダイレクト)
文字列生成関数を呼び出してテスト実行
(1) 整数1 < 整数2
(2) 整数1 > 整数2
(3) 整数1 == 整数2
(注) LLMの生成結果は毎回一定ではないため、結果によっては上記内容通りではないことが考えられます。
生成コードの実行結果
sample_code.c : 検証用プロンプトにて生成されたコードsample_test.c : 生成されたテストコード
$ gcc -Wall -o sample_code sample_code.c
$ gcc -Wall -o sample_test sample_test.c
sample_test.c: In function ‘main’:
sample_test.c:19:9: warning: implicit declaration of function ‘strcmp’ [-Wimplicit-function-declaration]
19 | if (strcmp(buffer, "1 2 3 4 5") == 0) {
| ^~~~~~
sample_test.c:3:1: note: include ‘<string.h>’ or provide a declaration of ‘strcmp’
2 | #include <stdlib.h>
+++ |+#include <string.h>
3 |
/bin/ld: /tmp/ccROUlDP.o: in function `main':
sample_test.c:(.text+0x54): undefined reference to `generate_output'
/bin/ld: sample_test.c:(.text+0x13a): undefined reference to `generate_output'
/bin/ld: sample_test.c:(.text+0x211): undefined reference to `generate_output'
collect2: error: ld returned 1 exit status
$ vi sample_test.c ← main()関数重複エラー解消のため条件付きコンパイル用の#ifndefマクロを追加
$ gcc -D TEST_MAIN -Wall -o sample_test sample_code.c sample_test.c
sample_test.c: In function ‘main’:
sample_test.c:25:9: warning: implicit declaration of function ‘strcmp’ [-Wimplicit-function-declaration]
25 | if (strcmp(buffer, "1 2 3 4 5 ") == 0) {
| ^~~~~~
sample_test.c:3:1: note: include ‘<string.h>’ or provide a declaration of ‘strcmp’
2 | #include <stdlib.h>
+++ |+#include <string.h>
3 |
$ ./sample_code 1 5
1 2 3 4 5 $ ./sample_code -3 3
-3 -2 -1 0 1 2 3 $ ./sample_code 1 1
1 $ ./sample_code 5 1
$ ./sample_test ← stdoutのリダイレクト先を/dev/nullから変更など修正箇所多数
Test Case 1:
Expected: 1 2 3 4 5
Test Case 1 Passed.
Test Case 2:
Expected: (no output)
Test Case 2 Passed.
Test Case 3:
Expected: 3
Test Case 3 Passed.
(3) temperature=0.15; top_p=0.5; top_k=--
2026-07-14
total duration: 22.886408388s
load duration: 73.241507ms
prompt eval count: 276 token(s)
prompt eval duration: 32.542963ms
prompt eval rate: 8481.10 tokens/s
eval count: 738 token(s)
eval duration: 22.415307159s
eval rate: 32.92 tokens/s
コード生成結果の概要
・C言語による生成
・コード以外にコンパイル方法と使用法を出力
・コードの記述スタイルのオールマン指定を無視
・戻り値は stdlib.h の EXIT_*** を使用
・文字列生成関数
文字列生成ではなく出力
・main()
引数個数のチェック(エラー処理有)
文字列生成関数の呼び出し
・テストコードを別途生成
main()を伴うテストコード
メモリーバッファへの読み書きのためfmemopen()とrewind()を使用
fscanf()で整数毎に読み込んだ出力値を、インクリメントとした整数を期待値として順に比較
文字列生成関数を呼び出してテスト実行
(1) 整数1 < 整数2
(注) LLMの生成結果は毎回一定ではないため、結果によっては上記内容通りではないことが考えられます。
生成コードの実行結果
sample_code.c : 検証用プロンプトにて生成されたコードsample_test.c : 生成されたテストコード
$ gcc -Wall -o sample_code sample_code.c
$ gcc -Wall -o sample_test sample_test.c
sample_test.c: In function ‘test_generate_output’:
sample_test.c:21:10: warning: unused variable ‘buffer’ [-Wunused-variable]
21 | char buffer[100];
| ^~~~~~
/bin/ld: /tmp/ccH9IS04.o: in function `test_generate_output':
sample_test.c:(.text+0x50): undefined reference to `generate_output'
collect2: error: ld returned 1 exit status
$ vi sample_code.c ← main()関数重複エラー解消のため条件付きコンパイル用の#ifndefマクロを追加
$ gcc -D TEST_MAIN -Wall -o sample_test sample_code.c sample_test.c
sample_test.c: In function ‘test_generate_output’:
sample_test.c:21:10: warning: unused variable ‘buffer’ [-Wunused-variable]
21 | char buffer[100];
| ^~~~~~
$ ./sample_code 1 5
1 2 3 4 5 $ ./sample_code -3 3
-3 -2 -1 0 1 2 3 $ ./sample_code 1 1
1 $ ./sample_code 5 1
$ ./sample_test
Running test for generate_output...
1 2 3 4 5 Test passed. ← 標準出力をキャプチャできていない
$ vi sample_test.c ← 書き直しレベルで修正
$ gcc -D TEST_MAIN -Wall -o sample_test sample_code.c sample_test.c
$ ./sample_test
Running test for generate_output...
Test passed.
(4) temperature=0.15; top_p=0.4; top_k=--
2026-07-14
total duration: 23.2749173s
load duration: 54.830588ms
prompt eval count: 276 token(s)
prompt eval duration: 38.642436ms
prompt eval rate: 7142.41 tokens/s
eval count: 752 token(s)
eval duration: 22.809550627s
eval rate: 32.97 tokens/s
コード生成結果の概要
・C言語による生成
・コード以外にコンパイル方法と使用法を出力
・コードの記述スタイルのオールマン指定を無視
・戻り値は stdlib.h の EXIT_*** を使用
・文字列生成関数
文字列生成ではなく出力
・main()
引数個数のチェック(エラー処理有)
文字列生成関数の呼び出し
・テストコードを別途生成
main()を伴うテストコード
dup2()でstdoutにファイル出力を複写することでテスト結果をファイル出力
ファイル内容と期待値を比較
(1) 整数1 < 整数2
(注) LLMの生成結果は毎回一定ではないため、結果によっては上記内容通りではないことが考えられます。
生成コードの実行結果
sample_code.c : 検証用プロンプトにて生成されたコードsample_test.c : 生成されたテストコード
$ gcc -Wall -o sample_code sample_code.c
$ gcc -Wall -o sample_test sample_test.c
sample_test.c: In function ‘test_generate_output’:
sample_test.c:14:24: warning: implicit declaration of function ‘dup’ [-Wimplicit-function-declaration]
14 | int saved_stdout = dup(fileno(stdout));
| ^~~
sample_test.c:15:5: warning: implicit declaration of function ‘dup2’ [-Wimplicit-function-declaration]
15 | dup2(fileno(output), fileno(stdout));
| ^~~~
sample_test.c:35:9: warning: implicit declaration of function ‘strcmp’ [-Wimplicit-function-declaration]
35 | if (strcmp(expected, buffer) == 0) {
| ^~~~~~
sample_test.c:3:1: note: include ‘<string.h>’ or provide a declaration of ‘strcmp’
2 | #include <stdlib.h>
+++ |+#include <string.h>
3 |
/bin/ld: /tmp/ccmuYHen.o: in function `test_generate_output':
sample_test.c:(.text+0xa9): undefined reference to `generate_output'
collect2: error: ld returned 1 exit status
$ vi sample_code.c ← main()関数重複エラー解消のため条件付きコンパイル用の#ifndefマクロを追加
$ gcc -D TEST_MAIN -Wall -o sample_test sample_code.c sample_test.c
sample_test.c: In function ‘test_generate_output’:
sample_test.c:14:24: warning: implicit declaration of function ‘dup’ [-Wimplicit-function-declaration]
14 | int saved_stdout = dup(fileno(stdout));
| ^~~
sample_test.c:15:5: warning: implicit declaration of function ‘dup2’ [-Wimplicit-function-declaration]
15 | dup2(fileno(output), fileno(stdout));
| ^~~~
sample_test.c:35:9: warning: implicit declaration of function ‘strcmp’ [-Wimplicit-function-declaration]
35 | if (strcmp(expected, buffer) == 0) {
| ^~~~~~
sample_test.c:3:1: note: include ‘<string.h>’ or provide a declaration of ‘strcmp’
2 | #include <stdlib.h>
+++ |+#include <string.h>
3 |
$ ./sample_code 1 5
1 2 3 4 5 $ ./sample_code -3 3
-3 -2 -1 0 1 2 3 $ ./sample_code 1 1
1 $ ./sample_code 5 1
$ ./sample_test
1 2 3 4 5 Test failed.
$ vi sample_test.c ← #include <unistd.h> と fflush(stdout) を追加
$ gcc -D TEST_MAIN -Wall -o sample_test sample_code.c sample_test.c
sample_test.c: In function ‘test_generate_output’:
sample_test.c:37:9: warning: implicit declaration of function ‘strcmp’ [-Wimplicit-function-declaration]
37 | if (strcmp(expected, buffer) == 0) {
| ^~~~~~
sample_test.c:4:1: note: include ‘<string.h>’ or provide a declaration of ‘strcmp’
3 | #include <unistd.h>
+++ |+#include <string.h>
4 |
$ ./sample_test
Test passed.
(5) temperature=0.15; top_p=0.7; top_k=32
2026-07-14
total duration: 24.902921936s
load duration: 47.177633ms
prompt eval count: 276 token(s)
prompt eval duration: 43.913061ms
prompt eval rate: 6285.15 tokens/s
eval count: 804 token(s)
eval duration: 24.418660068s
eval rate: 32.93 tokens/s
コード生成結果の概要
・C言語による生成
・コード以外にコンパイル方法と使用法を出力
・コードの記述スタイルのオールマン指定を無視
・戻り値は stdlib.h の EXIT_*** を使用
・文字列生成関数
文字列生成ではなく出力
・main()
引数個数のチェック(エラー処理有)
文字列生成関数の呼び出し
・テストコードを別途生成
main()を伴うテストコード
メモリーバッファへの読み書きのためfmemopen()とrewind()を使用
テスト結果は判定無しの比較出力のみ
(1) 整数1 < 整数2
(2) 整数1 > 整数2 ただし 整数1が負数
(3) 整数1 == 整数2
(注) LLMの生成結果は毎回一定ではないため、結果によっては上記内容通りではないことが考えられます。
生成コードの実行結果
sample_code.c : 検証用プロンプトにて生成されたコードsample_test.c : 生成されたテストコード
$ gcc -Wall -o sample_code sample_code.c
$ gcc -Wall -o sample_test sample_test.c
sample_test.c: In function ‘test_generate_output’:
sample_test.c:18:5: warning: implicit declaration of function ‘generate_output’; did you mean ‘test_generate_output’? [-Wimplicit-function-declaration]
18 | generate_output(start, end);
| ^~~~~~~~~~~~~~~
| test_generate_output
sample_test.c: At top level:
sample_test.c:39:6: warning: conflicting types for ‘generate_output’; have ‘void(int, int)’
39 | void generate_output(int start, int end) {
| ^~~~~~~~~~~~~~~
sample_test.c:18:5: note: previous implicit declaration of ‘generate_output’ with type ‘void(int, int)’
18 | generate_output(start, end);
| ^~~~~~~~~~~~~~~
$ vi sample_test.c ← main() の前で generate_output() を定義
$ gcc -Wall -o sample_test sample_test.c
$ ./sample_code 1 5
1 2 3 4 5 $ ./sample_code -3 3
-3 -2 -1 0 1 2 3 $ ./sample_code 1 1
1 $ ./sample_code 5 1
$ ./sample_test
Test: generate_output(1, 5)
Expected: 1 2 3 4 5
Got: ← 標準出力をキャプチャできていない
Test: generate_output(-3, 2)
Expected: -3 -2 -1 0 1 2
Got:
Test: generate_output(0, 0)
Expected: 0
Got:
$ vi sample_test.c ← 書き直しレベルで修正
$ gcc -Wall -o sample_test sample_test.c
$ ./sample_test
Test: generate_output(1, 5)
Expected: 1 2 3 4 5
Got: 1 2 3 4 5
Test: generate_output(-3, 2)
Expected: -3 -2 -1 0 1 2
Got: -3 -2 -1 0 1 2
Test: generate_output(0, 0)
Expected: 0
Got: 0
(6) temperature=0.15; top_p=0.7; top_k=16
2026-07-14
total duration: 22.853093075s
load duration: 85.080857ms
prompt eval count: 276 token(s)
prompt eval duration: 48.635961ms
prompt eval rate: 5674.81 tokens/s
eval count: 738 token(s)
eval duration: 22.3596447s
eval rate: 33.01 tokens/s
コード生成結果の概要
・C言語による生成
・コード以外にコンパイル方法と使用法を出力
・コードの記述スタイルのオールマン指定を無視
・戻り値は stdlib.h の EXIT_*** を使用
・文字列生成関数
文字列生成ではなく出力
・main()
引数個数のチェック(エラー処理有)
文字列生成関数の呼び出し
・テストコードを別途生成
main()を伴うテストコード
テスト結果は判定無しの比較出力のみ
(1) 整数1 < 整数2
(2) 整数1 > 整数2 ただし 整数1が負数
(3) 整数1 == 整数2
(4) 整数1 < 整数2
(注) LLMの生成結果は毎回一定ではないため、結果によっては上記内容通りではないことが考えられます。
生成コードの実行結果
sample_code.c : 検証用プロンプトにて生成されたコードsample_test.c : 生成されたテストコード
$ gcc -Wall -o sample_code sample_code.c
$ gcc -Wall -o sample_test sample_test.c
$ ./sample_code 1 5
1 2 3 4 5
$ ./sample_code -3 3
-3 -2 -1 0 1 2 3
$ ./sample_code 1 1
1
$ ./sample_code 5 1
$ ./sample_test
Test Case 1:
1 2 3 4 5
Expected Output: 1 2 3 4 5
Test Case 2:
-3 -2 -1 0 1 2
Expected Output: -3 -2 -1 0 1 2
Test Case 3:
4
Expected Output: 4
Test Case 4:
Expected Output: (No output expected)
(7) temperature=0.10; top_p=0.7; top_k=--
2026-07-14
total duration: 25.086846251s
load duration: 68.684498ms
prompt eval count: 276 token(s)
prompt eval duration: 40.127952ms
prompt eval rate: 6878.00 tokens/s
eval count: 808 token(s)
eval duration: 24.57748411s
eval rate: 32.88 tokens/s
コード生成結果の概要
・C言語による生成
・コード以外にコンパイル方法と使用法を出力
・コードの記述スタイルのオールマン指定を無視
・戻り値は stdlib.h の EXIT_*** を使用
・文字列生成関数
文字列生成ではなく出力
・main()
引数個数のチェック(エラー処理有)
文字列生成関数の呼び出し
・テストコードを別途生成
main()を伴うテストコード
テスト結果は判定無しの比較出力のみ
(1) 整数1 < 整数2
(2) 整数1 > 整数2 ただし 整数1が負数
(3) 整数1 == 整数2
(4) 整数1 < 整数2
(注) LLMの生成結果は毎回一定ではないため、結果によっては上記内容通りではないことが考えられます。
生成コードの実行結果
sample_code.c : 検証用プロンプトにて生成されたコードsample_test.c : 生成されたテストコード
$ gcc -Wall -o sample_code sample_code.c
$ gcc -Wall -o sample_test sample_test.c
sample_test.c: In function ‘test_generate_output’:
sample_test.c:21:10: warning: unused variable ‘buffer’ [-Wunused-variable]
21 | char buffer[100];
| ^~~~~~
/bin/ld: /tmp/ccfxuaBf.o: in function `test_generate_output':
sample_test.c:(.text+0x50): undefined reference to `generate_output'
collect2: error: ld returned 1 exit status
$ vi sample_code.c ← main()関数重複エラー解消のため条件付きコンパイル用の#ifndefマクロを追加
$ gcc -D TEST_MAIN -Wall -o sample_test sample_code.c sample_test.c
sample_test.c: In function ‘test_generate_output’:
sample_test.c:21:10: warning: unused variable ‘buffer’ [-Wunused-variable]
21 | char buffer[100];
| ^~~~~~
$ ./sample_code 1 5
1 2 3 4 5 devusr $ ./sample_code -3 3
-3 -2 -1 0 1 2 3 $ ./sample_code 1 1
1 $ ./sample_code 5 1
$ ./sample_test
Test failed: Output length mismatch ← テスト失敗
$ vi sample_test.c ← 標準出力のキャプチャ関連で修正多数
$ gcc -D TEST_MAIN -Wall -o sample_test sample_code.c sample_test.c
$ ./sample_test
All tests passed.