#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_helper(int *fd) {
  int rc;
  system("insmod "
         "tracer_helper"
         ".ko");
  rc = open("/dev/helper", 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",
            244);
        perror("init helper");
      } while (0);
      exit(EXIT_FAILURE);
    }
  } while (0);
  *fd = rc;
}


x86 assembly (clang, -O0):
<init_helper>:
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    0xea0(%rip),%rdi
call   1050 <open@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    11ca <init_helper+0x7a>
jmp    118f <init_helper+0x3f>
mov    0x2e42(%rip),%rax
mov    (%rax),%edi
lea    0xe85(%rip),%rsi
lea    0xe89(%rip),%rdx
mov    $0xf4,%ecx
call   1040 <fprintf@plt>
lea    0xf36(%rip),%rdi
call   1060 <perror@plt>
mov    0x2e0d(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
jmp    11cf <init_helper+0x7f>
mov    -0xc(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
add    $0x10,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
@.str = [24 x i8] c"insmod tracer_helper.ko\00"
@.str.1 = [12 x i8] c"/dev/helper\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 = [12 x i8] c"init helper\00"
@EXIT_FAILURE = global i32 0
define void @init_helper(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
store i32* %0, i32** %2
%4 = call i32 @system(i8* getelementptr inbounds ([24 x i8], [24 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 244)
%14 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 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 = [24 x i8] c"insmod tracer_helper.ko\00"
@.str.1 = [12 x i8] c"/dev/helper\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 = [12 x i8] c"init helper\00"
@EXIT_FAILURE = global i32 0
define void @init_helper(i32* nocapture writeonly %0) {
%2 = tail call i32 @system(i8* getelementptr inbounds ([24 x i8], [24 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 244)
%9 = tail call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 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
}