#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 */
typedef int /*<<< orphan*/ int16_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ hj_parse(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ int16_or_die(char *);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int /*<<< orphan*/ *term_open(char *);
int main(int argc, char **argv) {
  if (argc < 4) {
    fprintf(stderr, "usage: %s <file> <motor a> <motor b>\n",
            argc ? argv[0] : "hj");
    return -1;
  }
  FILE *sf = term_open(argv[1]);
  if (!sf) {
    do {
      fputs("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
            "2022-01-22/02-19-57/repos/jmesmon/half_jackal/refs/heads/master/"
            "pc/maintain_speed.c"
            ":"
            "101"
            ":",
            stderr);
      fprintf(stderr, "open: %s", strerror(errno));
      fputc('\n', stderr);
    } while (0);
    return -1;
  }
  int16_t motors[2];
  motors[0] = int16_or_die(argv[2]);
  motors[1] = int16_or_die(argv[3]);
  hj_parse(sf, motors);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x4,-0x8(%rbp)
jge    11e5 <main+0x75>
mov    0x2e49(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     11b6 <main+0x46>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
jmp    11c6 <main+0x56>
lea    0xe69(%rip),%rax
mov    %rax,-0x30(%rbp)
jmp    11c6 <main+0x56>
mov    -0x24(%rbp),%edi
mov    -0x30(%rbp),%rdx
lea    0xe2c(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    129a <main+0x12a>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1080 <term_open@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1266 <main+0xf6>
jmp    1206 <main+0x96>
mov    0x2dd3(%rip),%rax
mov    (%rax),%esi
lea    0xe13(%rip),%rdi
call   1030 <fputs@plt>
mov    0x2dbe(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
mov    0x2daa(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    -0x34(%rbp),%edi
mov    %rax,%rdx
lea    0xe80(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2d92(%rip),%rax
mov    (%rax),%esi
mov    $0xa,%edi
call   1040 <fputc@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    129a <main+0x12a>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1070 <int16_or_die@plt>
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1070 <int16_or_die@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1060 <hj_parse@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
cmp    $0x3,%edi
jg     1190 <main+0x20>
mov    %edi,%eax
mov    0x2e5b(%rip),%rcx
mov    (%rcx),%edi
test   %eax,%eax
je     11c9 <main+0x59>
mov    (%rbx),%rdx
jmp    11d0 <main+0x60>
mov    0x8(%rbx),%rdi
call   1080 <term_open@plt>
test   %rax,%rax
je     11de <main+0x6e>
mov    %rax,%r14
mov    0x10(%rbx),%rdi
call   1070 <int16_or_die@plt>
mov    %eax,(%rsp)
mov    0x18(%rbx),%rdi
call   1070 <int16_or_die@plt>
mov    %eax,0x4(%rsp)
mov    %rsp,%rsi
mov    %r14,%rdi
call   1060 <hj_parse@plt>
xor    %eax,%eax
jmp    1228 <main+0xb8>
lea    0xe56(%rip),%rdx
lea    0xe29(%rip),%rsi
call   1050 <fprintf@plt>
jmp    1223 <main+0xb3>
mov    0x2dfb(%rip),%r14
mov    (%r14),%esi
lea    0xe3a(%rip),%rdi
call   1030 <fputs@plt>
mov    (%r14),%ebx
mov    0x2dda(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
lea    0xeb6(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
call   1050 <fprintf@plt>
mov    (%r14),%esi
mov    $0xa,%edi
call   1040 <fputc@plt>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [38 x i8] c"usage: %s <file> <motor a> <motor b>\0A\00"
@.str.1 = [3 x i8] c"hj\00"
@.str.2 = [153 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/jmesmon/half_jackal/refs/heads/master/pc/maintain_speed.c:101:\00"
@.str.3 = [9 x i8] c"open: %s\00"
@errno = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca [2 x i32]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 4
br i1 %9, label %10, label %22
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = load i32, i32* %4
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %18
14: ; preds = %10
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 0
%17 = load i8*, i8** %16
br label %19
18: ; preds = %10
br label %19
19: ; preds = %18, %14
%20 = phi i8* [ %17, %14 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), %18 ]
%21 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8* %20)
store i32 -1, i32* %3
br label %54
22: ; preds = %2
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
%26 = call i32* @term_open(i8* %25)
store i32* %26, i32** %6
%27 = load i32*, i32** %6
%28 = icmp ne i32* %27, null
br i1 %28, label %40, label %29
29: ; preds = %22
br label %30
30: ; preds = %29
%31 = load i32, i32* @stderr
%32 = call i32 @fputs(i8* getelementptr inbounds ([153 x i8], [153 x i8]* @.str.2, i64 0, i64 0), i32 %31)
%33 = load i32, i32* @stderr
%34 = load i32, i32* @errno
%35 = call i8* @strerror(i32 %34)
%36 = call i32 @fprintf(i32 %33, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* %35)
%37 = load i32, i32* @stderr
%38 = call i32 @fputc(i8 signext 10, i32 %37)
br label %39
39: ; preds = %30
store i32 -1, i32* %3
br label %54
40: ; preds = %22
%41 = load i8**, i8*** %5
%42 = getelementptr inbounds i8*, i8** %41, i64 2
%43 = load i8*, i8** %42
%44 = call i32 @int16_or_die(i8* %43)
%45 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 0
store i32 %44, i32* %45
%46 = load i8**, i8*** %5
%47 = getelementptr inbounds i8*, i8** %46, i64 3
%48 = load i8*, i8** %47
%49 = call i32 @int16_or_die(i8* %48)
%50 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 1
store i32 %49, i32* %50
%51 = load i32*, i32** %6
%52 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 0
%53 = call i32 @hj_parse(i32* %51, i32* %52)
store i32 0, i32* %3
br label %54
54: ; preds = %40, %39, %19
%55 = load i32, i32* %3
ret i32 %55
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [38 x i8] c"usage: %s <file> <motor a> <motor b>\0A\00"
@.str.1 = [3 x i8] c"hj\00"
@.str.2 = [153 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/jmesmon/half_jackal/refs/heads/master/pc/maintain_speed.c:101:\00"
@.str.3 = [9 x i8] c"open: %s\00"
@errno = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [2 x i32]
%4 = icmp slt i32 %0, 4
br i1 %4, label %5, label %13
5: ; preds = %2
%6 = load i32, i32* @stderr
%7 = icmp eq i32 %0, 0
br i1 %7, label %10, label %8
8: ; preds = %5
%9 = load i8*, i8** %1
br label %10
10: ; preds = %5, %8
%11 = phi i8* [ %9, %8 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), %5 ]
%12 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8* %11)
br label %38
13: ; preds = %2
%14 = getelementptr inbounds i8*, i8** %1, i64 1
%15 = load i8*, i8** %14
%16 = tail call i32* @term_open(i8* %15)
%17 = icmp eq i32* %16, null
br i1 %17, label %18, label %27
18: ; preds = %13
%19 = load i32, i32* @stderr
%20 = tail call i32 @fputs(i8* getelementptr inbounds ([153 x i8], [153 x i8]* @.str.2, i64 0, i64 0), i32 %19)
%21 = load i32, i32* @stderr
%22 = load i32, i32* @errno
%23 = tail call i8* @strerror(i32 %22)
%24 = tail call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* %23)
%25 = load i32, i32* @stderr
%26 = tail call i32 @fputc(i8 signext 10, i32 %25)
br label %38
27: ; preds = %13
%28 = bitcast [2 x i32]* %3 to i8*
%29 = getelementptr inbounds i8*, i8** %1, i64 2
%30 = load i8*, i8** %29
%31 = tail call i32 @int16_or_die(i8* %30)
%32 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
store i32 %31, i32* %32
%33 = getelementptr inbounds i8*, i8** %1, i64 3
%34 = load i8*, i8** %33
%35 = tail call i32 @int16_or_die(i8* %34)
%36 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
store i32 %35, i32* %36
%37 = call i32 @hj_parse(i32* %16, i32* %32)
br label %38
38: ; preds = %18, %27, %10
%39 = phi i32 [ -1, %10 ], [ 0, %27 ], [ -1, %18 ]
ret i32 %39
}