int test_read_toc() {
  char cmd[12] = {0x14, 0, 0, 0x00, 0x0C, 0, 0, 0, 0, 0, 0, 0};
  char expect[12] = {0x41, 0,    0,    0x96, 0x41, 0,
                     0x2E, 0x4C, 0xFF, 0xFF, 0xFF, 0xFF};
  if (ide_test_packet_ok("/scratch/repos/new/home/jordi_armengol_estape/"
                         "c-scraper/outputs/2022-01-22/02-19-57/repos/Aishou/"
                         "lxdream/refs/heads/master/test/testide.c",
                         478, __func__, cmd, expect, 12) != 0) {
    return -1;
  };
  return 0;
}


x86 assembly (clang, -O0):
<test_read_toc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0xee1(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0xedf(%rip),%eax
mov    %eax,-0x8(%rbp)
mov    0xed9(%rip),%rax
mov    %rax,-0x1c(%rbp)
mov    0xed7(%rip),%eax
mov    %eax,-0x14(%rbp)
lea    -0x10(%rbp),%rcx
lea    -0x1c(%rbp),%r8
lea    0xec9(%rip),%rdi
mov    $0x1de,%esi
lea    0xf47(%rip),%rdx
mov    $0xc,%r9d
mov    $0x0,%al
call   1030 <ide_test_packet_ok@plt>
cmp    $0x0,%eax
je     117d <test_read_toc+0x6d>
movl   $0xffffffff,-0x4(%rbp)
jmp    1184 <test_read_toc+0x74>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_read_toc>:
sub    $0x28,%rsp
movabs $0xc00000014,%rax
mov    %rax,0x18(%rsp)
movl   $0x0,0x20(%rsp)
movabs $0x4c2e004196000041,%rax
mov    %rax,0x8(%rsp)
movl   $0xffffffff,0x10(%rsp)
ff
lea    0xecf(%rip),%rdi
lea    0xf52(%rip),%rdx
lea    0x18(%rsp),%rcx
lea    0x8(%rsp),%r8
mov    $0x1de,%esi
mov    $0xc,%r9d
xor    %eax,%eax
call   1030 <ide_test_packet_ok@plt>
neg    %eax
sbb    %eax,%eax
add    $0x28,%rsp
ret

LLVM IR (-O0):
@__const.test_read_toc.cmd = [12 x i8] c"\14\00\00\00\0C\00\00\00\00\00\00\00"
@__const.test_read_toc.expect = [12 x i8] c"A\00\00\96A\00.L\FF\FF\FF\FF"
@.str = [138 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/Aishou/lxdream/refs/heads/master/test/testide.c\00"
@__func__.test_read_toc = [14 x i8] c"test_read_toc\00"
define i32 @test_read_toc() {
%1 = alloca i32
%2 = alloca [12 x i8]
%3 = alloca [12 x i8]
%4 = bitcast [12 x i8]* %2 to i8*
%5 = bitcast [12 x i8]* %3 to i8*
%6 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 0
%7 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 0
%8 = call i32 (i8*, i32, i8*, i8*, i8*, i32, ...) bitcast (i32 (...)* @ide_test_packet_ok to i32 (i8*, i32, i8*, i8*, i8*, i32, ...)*)(i8* getelementptr inbounds ([138 x i8], [138 x i8]* @.str, i64 0, i64 0), i32 478, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @__func__.test_read_toc, i64 0, i64 0), i8* %6, i8* %7, i32 12)
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %0
store i32 -1, i32* %1
br label %12
11: ; preds = %0
store i32 0, i32* %1
br label %12
12: ; preds = %11, %10
%13 = load i32, i32* %1
ret i32 %13
}

LLVM IR (-O2):
@__const.test_read_toc.cmd = [12 x i8] c"\14\00\00\00\0C\00\00\00\00\00\00\00"
@__const.test_read_toc.expect = [12 x i8] c"A\00\00\96A\00.L\FF\FF\FF\FF"
@.str = [138 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/Aishou/lxdream/refs/heads/master/test/testide.c\00"
@__func__.test_read_toc = [14 x i8] c"test_read_toc\00"
define i32 @test_read_toc() {
%1 = alloca [12 x i8]
%2 = alloca [12 x i8]
%3 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 0
%5 = call i32 (i8*, i32, i8*, i8*, i8*, i32, ...) bitcast (i32 (...)* @ide_test_packet_ok to i32 (i8*, i32, i8*, i8*, i8*, i32, ...)*)(i8* getelementptr inbounds ([138 x i8], [138 x i8]* @.str, i64 0, i64 0), i32 478, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @__func__.test_read_toc, i64 0, i64 0), i8* %3, i8* %4, i32 12)
%6 = icmp ne i32 %5, 0
%7 = sext i1 %6 to i32
ret i32 %7
}