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

/* Variables and functions */
int /*<<< orphan*/ accept(int, char *);
char *extend(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int fscanf(int /*<<< orphan*/ *, char *, int *);
int /*<<< orphan*/ perror(char *);
void load(char *name) {
  FILE *f = fopen(name = extend(name), "r");
  if (!f)
    perror(name);
  else {
    int lineNumber;
    char lineText[1024];
    while ((1 == fscanf(f, " %d ", &lineNumber)) &&
           fgets(lineText, sizeof(lineText), f))
      accept(lineNumber, lineText);
    fclose(f);
  }
}


x86 assembly (clang, -O0):
<load>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1090 <extend@plt>
mov    %rax,%rdi
mov    %rdi,-0x8(%rbp)
lea    0xe6a(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11b8 <load+0x48>
mov    -0x8(%rbp),%rdi
call   1070 <perror@plt>
jmp    123a <load+0xca>
jmp    11bd <load+0x4d>
mov    -0x10(%rbp),%rdi
lea    0xe3a(%rip),%rsi
lea    -0x14(%rbp),%rdx
call   1040 <fscanf@plt>
mov    %eax,%edx
xor    %eax,%eax
mov    $0x1,%ecx
cmp    %edx,%ecx
mov    %al,-0x421(%rbp)
jne    120a <load+0x9a>
lea    -0x420(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x400,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x421(%rbp)
mov    -0x421(%rbp),%al
test   $0x1,%al
jne    121d <load+0xad>
jmp    1231 <load+0xc1>
mov    -0x14(%rbp),%edi
lea    -0x420(%rbp),%rsi
call   1080 <accept@plt>
jmp    11bd <load+0x4d>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<load>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x418,%rsp
call   1090 <extend@plt>
mov    %rax,%r14
lea    0xe73(%rip),%rsi
mov    %rax,%rdi
call   1060 <fopen@plt>
test   %rax,%rax
je     121b <load+0xab>
mov    %rax,%rbx
lea    0xe5a(%rip),%rsi
lea    0xc(%rsp),%rdx
mov    %rax,%rdi
call   1040 <fscanf@plt>
cmp    $0x1,%eax
jne    1204 <load+0x94>
lea    0x10(%rsp),%r14
lea    0xe3c(%rip),%r15
lea    0xc(%rsp),%r12
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    $0x400,%esi
mov    %rbx,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     1204 <load+0x94>
mov    0xc(%rsp),%edi
mov    %r14,%rsi
call   1080 <accept@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1040 <fscanf@plt>
cmp    $0x1,%eax
je     11d0 <load+0x60>
mov    %rbx,%rdi
call   1030 <fclose@plt>
add    $0x418,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
mov    %r14,%rdi
add    $0x418,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1070 <perror@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [5 x i8] c" %d \00"
define void @load(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca i32
%5 = alloca [1024 x i8]
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = call i8* @extend(i8* %6)
store i8* %7, i8** %2
%8 = call i32* @fopen(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %8, i32** %3
%9 = load i32*, i32** %3
%10 = icmp ne i32* %9, null
br i1 %10, label %14, label %11
11: ; preds = %1
%12 = load i8*, i8** %2
%13 = call i32 @perror(i8* %12)
br label %33
14: ; preds = %1
br label %15
15: ; preds = %26, %14
%16 = load i32*, i32** %3
%17 = call i32 @fscanf(i32* %16, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%18 = icmp eq i32 1, %17
br i1 %18, label %19, label %24
19: ; preds = %15
%20 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%21 = load i32*, i32** %3
%22 = call i64 @fgets(i8* %20, i32 1024, i32* %21)
%23 = icmp ne i64 %22, 0
br label %24
24: ; preds = %19, %15
%25 = phi i1 [ false, %15 ], [ %23, %19 ]
br i1 %25, label %26, label %30
26: ; preds = %24
%27 = load i32, i32* %4
%28 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%29 = call i32 @accept(i32 %27, i8* %28)
br label %15
30: ; preds = %24
%31 = load i32*, i32** %3
%32 = call i32 @fclose(i32* %31)
br label %33
33: ; preds = %30, %11
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [5 x i8] c" %d \00"
define void @load(i8* %0) {
%2 = alloca i32
%3 = alloca [1024 x i8]
%4 = tail call i8* @extend(i8* %0)
%5 = tail call i32* @fopen(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %9
7: ; preds = %1
%8 = tail call i32 @perror(i8* %4)
br label %24
9: ; preds = %1
%10 = bitcast i32* %2 to i8*
%11 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%12 = call i32 @fscanf(i32* %5, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%13 = icmp eq i32 %12, 1
br i1 %13, label %14, label %22
14: ; preds = %9, %17
%15 = call i64 @fgets(i8* %11, i32 1024, i32* %5)
%16 = icmp eq i64 %15, 0
br i1 %16, label %22, label %17
17: ; preds = %14
%18 = load i32, i32* %2
%19 = call i32 @accept(i32 %18, i8* %11)
%20 = call i32 @fscanf(i32* %5, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%21 = icmp eq i32 %20, 1
br i1 %21, label %14, label %22
22: ; preds = %14, %17, %9
%23 = call i32 @fclose(i32* %5)
br label %24
24: ; preds = %22, %7
ret void
}