#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ system(char *);
void init_test2(int *fd) {
  int rc;
  system("insmod "
         "tracer"
         ".ko");
  rc = open("/dev/tracer", O_RDONLY);
  do {
    if (rc < 0) {
      do {
        fprintf(
            stderr, "(%s, %d): ",
            "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
            "2022-01-22/02-19-57/repos/walac/linux/refs/heads/master/tools/"
            "labs/templates/assignments/1-tracer/checker/_test/tracer_test.c",
            213);
        perror("init_test2");
      } while (0);
      exit(EXIT_FAILURE);
    }
  } while (0);
  *fd = rc;
}


x86 assembly (clang, -O0):
<init_test2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xe9d(%rip),%rdi
call   1030 <system@plt>
mov    0x2e79(%rip),%rax
mov    (%rax),%esi
lea    0xe99(%rip),%rdi
call   1050 <open@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    11ca <init_test2+0x7a>
jmp    118f <init_test2+0x3f>
mov    0x2e42(%rip),%rax
mov    (%rax),%edi
lea    0xe7e(%rip),%rsi
lea    0xe82(%rip),%rdx
mov    $0xd5,%ecx
call   1040 <fprintf@plt>
lea    0xf2f(%rip),%rdi
call   1060 <perror@plt>
mov    0x2e0d(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
jmp    11cf <init_test2+0x7f>
mov    -0xc(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<init_test2>:
push   %rbx
mov    %rdi,%rbx
lea    0xea5(%rip),%rdi
call   1030 <system@plt>
mov    0x2e81(%rip),%rax
mov    (%rax),%esi
lea    0xea1(%rip),%rdi
call   1050 <open@plt>
test   %eax,%eax
js     117d <init_test2+0x2d>
mov    %eax,(%rbx)
pop    %rbx
ret
mov    0x2e54(%rip),%rax
mov    (%rax),%edi
lea    0xe90(%rip),%rsi
lea    0xe94(%rip),%rdx
mov    $0xd5,%ecx
call   1040 <fprintf@plt>
lea    0xf41(%rip),%rdi
call   1060 <perror@plt>
mov    0x2e1f(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [17 x i8] c"insmod tracer.ko\00"
@.str.1 = [12 x i8] c"/dev/tracer\00"
@O_RDONLY = global i32 0
@stderr = global i32 0
@.str.2 = [11 x i8] c"(%s, %d): \00"
@.str.3 = [190 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/walac/linux/refs/heads/master/tools/labs/templates/assignments/1-tracer/checker/_test/tracer_test.c\00"
@.str.4 = [11 x i8] c"init_test2\00"
@EXIT_FAILURE = global i32 0
define void @init_test2(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
store i32* %0, i32** %2
%4 = call i32 @system(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%5 = load i32, i32* @O_RDONLY
%6 = call i32 @open(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %5)
store i32 %6, i32* %3
br label %7
7: ; preds = %1
%8 = load i32, i32* %3
%9 = icmp slt i32 %8, 0
br i1 %9, label %10, label %18
10: ; preds = %7
br label %11
11: ; preds = %10
%12 = load i32, i32* @stderr
%13 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([190 x i8], [190 x i8]* @.str.3, i64 0, i64 0), i32 213)
%14 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
br label %15
15: ; preds = %11
%16 = load i32, i32* @EXIT_FAILURE
%17 = call i32 @exit(i32 %16)
unreachable
18: ; preds = %7
br label %19
19: ; preds = %18
%20 = load i32, i32* %3
%21 = load i32*, i32** %2
store i32 %20, i32* %21
ret void
}

LLVM IR (-O2):
@.str = [17 x i8] c"insmod tracer.ko\00"
@.str.1 = [12 x i8] c"/dev/tracer\00"
@O_RDONLY = global i32 0
@stderr = global i32 0
@.str.2 = [11 x i8] c"(%s, %d): \00"
@.str.3 = [190 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/walac/linux/refs/heads/master/tools/labs/templates/assignments/1-tracer/checker/_test/tracer_test.c\00"
@.str.4 = [11 x i8] c"init_test2\00"
@EXIT_FAILURE = global i32 0
define void @init_test2(i32* nocapture writeonly %0) {
%2 = tail call i32 @system(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%3 = load i32, i32* @O_RDONLY
%4 = tail call i32 @open(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %3)
%5 = icmp slt i32 %4, 0
br i1 %5, label %6, label %12
6: ; preds = %1
%7 = load i32, i32* @stderr
%8 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([190 x i8], [190 x i8]* @.str.3, i64 0, i64 0), i32 213)
%9 = tail call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%10 = load i32, i32* @EXIT_FAILURE
%11 = tail call i32 @exit(i32 %10)
unreachable
12: ; preds = %1
store i32 %4, i32* %0
ret void
}