#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 */
struct word {
  int dummy;
};
typedef int /*<<< orphan*/ ssize_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ getline(char **, size_t *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printwlist(struct word *);
struct word *processline(char *, struct word *);
int main(int argc, char *argv[1]) {
  if (argc == 2) {
    FILE *fin = fopen(argv[1], "r");
    ssize_t len;
    char *linebuf = NULL;
    size_t linebuflen = 0;
    struct word *wlist = NULL;
    while ((len = getline(&linebuf, &linebuflen, fin)) > 0)
      wlist = processline(linebuf, wlist);
    fclose(fin);
    free(linebuf);
    printwlist(wlist);
    return 0;
  } else
    return 1;
}


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   $0x2,-0x8(%rbp)
jne    120a <main+0xaa>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe71(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
mov    -0x18(%rbp),%rdx
lea    -0x28(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1070 <getline@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0x0,%eax
jle    11e3 <main+0x83>
mov    -0x28(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   1050 <processline@plt>
mov    %rax,-0x38(%rbp)
jmp    11b0 <main+0x50>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x38(%rbp),%rdi
call   1080 <printwlist@plt>
movl   $0x0,-0x4(%rbp)
jmp    1211 <main+0xb1>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    $0x1,%r14d
cmp    $0x2,%edi
jne    120a <main+0xaa>
mov    0x8(%rsi),%rdi
lea    0xe79(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%r15
movq   $0x0,(%rsp)
movq   $0x0,0x8(%rsp)
mov    %rsp,%rdi
lea    0x8(%rsp),%rsi
mov    %rax,%rdx
call   1070 <getline@plt>
xor    %r14d,%r14d
xor    %ebx,%ebx
test   %eax,%eax
jle    11f1 <main+0x91>
mov    %rsp,%r12
lea    0x8(%rsp),%r13
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%rsp),%rdi
mov    %rbx,%rsi
call   1050 <processline@plt>
mov    %rax,%rbx
mov    %r12,%rdi
mov    %r13,%rsi
mov    %r15,%rdx
call   1070 <getline@plt>
test   %eax,%eax
jg     11d0 <main+0x70>
mov    %r15,%rdi
call   1040 <fclose@plt>
mov    (%rsp),%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1080 <printwlist@plt>
mov    %r14d,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.word = type { i32 }
@.str = [2 x i8] c"r\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i64
%10 = alloca %struct.word*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = icmp eq i32 %11, 2
br i1 %12, label %13, label %33
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i32* @fopen(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %17, i32** %6
store i8* null, i8** %8
store i64 0, i64* %9
store %struct.word* null, %struct.word** %10
br label %18
18: ; preds = %22, %13
%19 = load i32*, i32** %6
%20 = call i32 @getline(i8** %8, i64* %9, i32* %19)
store i32 %20, i32* %7
%21 = icmp sgt i32 %20, 0
br i1 %21, label %22, label %26
22: ; preds = %18
%23 = load i8*, i8** %8
%24 = load %struct.word*, %struct.word** %10
%25 = call %struct.word* @processline(i8* %23, %struct.word* %24)
store %struct.word* %25, %struct.word** %10
br label %18
26: ; preds = %18
%27 = load i32*, i32** %6
%28 = call i32 @fclose(i32* %27)
%29 = load i8*, i8** %8
%30 = call i32 @free(i8* %29)
%31 = load %struct.word*, %struct.word** %10
%32 = call i32 @printwlist(%struct.word* %31)
store i32 0, i32* %3
br label %34
33: ; preds = %2
store i32 1, i32* %3
br label %34
34: ; preds = %33, %26
%35 = load i32, i32* %3
ret i32 %35
}

LLVM IR (-O2):
%struct.word = type { i32 }
@.str = [2 x i8] c"r\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = icmp eq i32 %0, 2
br i1 %5, label %6, label %26
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32* @fopen(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%10 = bitcast i8** %3 to i8*
store i8* null, i8** %3
%11 = bitcast i64* %4 to i8*
store i64 0, i64* %4
%12 = call i32 @getline(i8** %3, i64* %4, i32* %9)
%13 = icmp sgt i32 %12, 0
br i1 %13, label %14, label %20
14: ; preds = %6, %14
%15 = phi %struct.word* [ %17, %14 ], [ null, %6 ]
%16 = load i8*, i8** %3
%17 = call %struct.word* @processline(i8* %16, %struct.word* %15)
%18 = call i32 @getline(i8** %3, i64* %4, i32* %9)
%19 = icmp sgt i32 %18, 0
br i1 %19, label %14, label %20
20: ; preds = %14, %6
%21 = phi %struct.word* [ null, %6 ], [ %17, %14 ]
%22 = call i32 @fclose(i32* %9)
%23 = load i8*, i8** %3
%24 = call i32 @free(i8* %23)
%25 = call i32 @printwlist(%struct.word* %21)
br label %26
26: ; preds = %2, %20
%27 = phi i32 [ 0, %20 ], [ 1, %2 ]
ret i32 %27
}