#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 */
scalar_t__ EOF;
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int);
int /*<<< orphan*/ free(char *);
scalar_t__ malloc(int);
scalar_t__ sscanf(char *, char *, char *, int *);
int /*<<< orphan*/ stderr;
char *get_token(char *s[]) {
  char *tmp = (char *)malloc(sizeof(char) * 128);
  if (!tmp) {
    fprintf(stderr,
            "%s:%d: error: "
            "failed to allocate memory\n",
            "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
            "2022-01-22/02-19-57/repos/locksten/calc/refs/heads/master/src/"
            "shunting_yard.c",
            155);
    exit(EXIT_FAILURE);
  }
  int n_moved;
  if (sscanf(*s, "%s%n", tmp, &n_moved) == EOF) {
    free(tmp);
    return NULL;
  }
  *s += n_moved;
  return tmp;
}


x86 assembly (clang, -O0):
<get_token>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    $0x80,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11a4 <get_token+0x54>
mov    0x2e5c(%rip),%rax
mov    (%rax),%edi
lea    0xe7b(%rip),%rsi
lea    0xe9d(%rip),%rdx
mov    $0x9b,%ecx
call   1040 <fprintf@plt>
mov    0x2e33(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x18(%rbp),%rdx
lea    0xf01(%rip),%rsi
lea    -0x1c(%rbp),%rcx
call   1060 <sscanf@plt>
mov    0x2e22(%rip),%rcx
cmp    (%rcx),%rax
jne    11e5 <get_token+0x95>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x8(%rbp)
jmp    1200 <get_token+0xb0>
mov    -0x1c(%rbp),%edx
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
movslq %edx,%rdx
add    %rdx,%rcx
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_token>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    $0x80,%edi
call   1050 <malloc@plt>
test   %rax,%rax
je     11ab <get_token+0x5b>
mov    %rax,%rbx
mov    (%r14),%rdi
lea    0xf44(%rip),%rsi
lea    0x4(%rsp),%rcx
mov    %rax,%rdx
call   1060 <sscanf@plt>
mov    0x2e61(%rip),%rcx
cmp    (%rcx),%rax
jne    1198 <get_token+0x48>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %ebx,%ebx
jmp    11a0 <get_token+0x50>
movslq 0x4(%rsp),%rax
add    %rax,(%r14)
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    0x2e26(%rip),%rax
mov    (%rax),%edi
lea    0xe45(%rip),%rsi
lea    0xe67(%rip),%rdx
mov    $0x9b,%ecx
call   1040 <fprintf@plt>
mov    0x2dfd(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [41 x i8] c"%s:%d: error: failed to allocate memory\0A\00"
@.str.1 = [142 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/locksten/calc/refs/heads/master/src/shunting_yard.c\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [5 x i8] c"%s%n\00"
@EOF = global i64 0
define i8* @get_token(i8** %0) {
%2 = alloca i8*
%3 = alloca i8**
%4 = alloca i8*
%5 = alloca i32
store i8** %0, i8*** %3
%6 = call i64 @malloc(i32 128)
%7 = inttoptr i64 %6 to i8*
store i8* %7, i8** %4
%8 = load i8*, i8** %4
%9 = icmp ne i8* %8, null
br i1 %9, label %15, label %10
10: ; preds = %1
%11 = load i32, i32* @stderr
%12 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([142 x i8], [142 x i8]* @.str.1, i64 0, i64 0), i32 155)
%13 = load i32, i32* @EXIT_FAILURE
%14 = call i32 @exit(i32 %13)
unreachable
15: ; preds = %1
%16 = load i8**, i8*** %3
%17 = load i8*, i8** %16
%18 = load i8*, i8** %4
%19 = call i64 @sscanf(i8* %17, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %18, i32* %5)
%20 = load i64, i64* @EOF
%21 = icmp eq i64 %19, %20
br i1 %21, label %22, label %25
22: ; preds = %15
%23 = load i8*, i8** %4
%24 = call i32 @free(i8* %23)
store i8* null, i8** %2
br label %32
25: ; preds = %15
%26 = load i32, i32* %5
%27 = load i8**, i8*** %3
%28 = load i8*, i8** %27
%29 = sext i32 %26 to i64
%30 = getelementptr inbounds i8, i8* %28, i64 %29
store i8* %30, i8** %27
%31 = load i8*, i8** %4
store i8* %31, i8** %2
br label %32
32: ; preds = %25, %22
%33 = load i8*, i8** %2
ret i8* %33
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [41 x i8] c"%s:%d: error: failed to allocate memory\0A\00"
@.str.1 = [142 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/locksten/calc/refs/heads/master/src/shunting_yard.c\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [5 x i8] c"%s%n\00"
@EOF = global i64 0
define i8* @get_token(i8** nocapture %0) {
%2 = alloca i32
%3 = tail call i64 @malloc(i32 128)
%4 = inttoptr i64 %3 to i8*
%5 = icmp eq i64 %3, 0
br i1 %5, label %6, label %11
6: ; preds = %1
%7 = load i32, i32* @stderr
%8 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([142 x i8], [142 x i8]* @.str.1, i64 0, i64 0), i32 155)
%9 = load i32, i32* @EXIT_FAILURE
%10 = tail call i32 @exit(i32 %9)
unreachable
11: ; preds = %1
%12 = bitcast i32* %2 to i8*
%13 = load i8*, i8** %0
%14 = call i64 @sscanf(i8* %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %4, i32* %2)
%15 = load i64, i64* @EOF
%16 = icmp eq i64 %14, %15
br i1 %16, label %17, label %19
17: ; preds = %11
%18 = call i32 @free(i8* %4)
br label %24
19: ; preds = %11
%20 = load i32, i32* %2
%21 = load i8*, i8** %0
%22 = sext i32 %20 to i64
%23 = getelementptr inbounds i8, i8* %21, i64 %22
store i8* %23, i8** %0
br label %24
24: ; preds = %19, %17
%25 = phi i8* [ null, %17 ], [ %4, %19 ]
ret i8* %25
}