#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*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ show_line_numbers(int /*<<< orphan*/ *);
int /*<<< orphan*/ *stdin;
int main(int argc, char **argv) {
  int arg_count = argc;
  char **arguments = argv;
  if (arg_count == 1) {
    show_line_numbers(stdin);
  } else {
    FILE *read = fopen(arguments[1], "r");
    if (read == NULL) {
      perror(arguments[1]);
    } else {
      show_line_numbers(read);
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
cmpl   $0x1,-0x14(%rbp)
jne    1172 <main+0x42>
mov    0x2e83(%rip),%rax
mov    (%rax),%rdi
call   1030 <show_line_numbers@plt>
jmp    11b5 <main+0x85>
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe7f(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11a7 <main+0x77>
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <perror@plt>
jmp    11b0 <main+0x80>
mov    -0x28(%rbp),%rdi
call   1030 <show_line_numbers@plt>
jmp    11b5 <main+0x85>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
cmp    $0x1,%edi
jne    1142 <main+0x12>
mov    0x2eab(%rip),%rax
mov    (%rax),%rdi
jmp    115d <main+0x2d>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xeb0(%rip),%rsi
call   1040 <fopen@plt>
test   %rax,%rax
je     1166 <main+0x36>
mov    %rax,%rdi
call   1030 <show_line_numbers@plt>
xor    %eax,%eax
pop    %rbx
ret
mov    0x8(%rbx),%rdi
call   1050 <perror@plt>
jmp    1162 <main+0x32>

LLVM IR (-O0):
@stdin = global i32* null
@.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 i8**
%8 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
store i32 %9, i32* %6
%10 = load i8**, i8*** %5
store i8** %10, i8*** %7
%11 = load i32, i32* %6
%12 = icmp eq i32 %11, 1
br i1 %12, label %13, label %16
13: ; preds = %2
%14 = load i32*, i32** @stdin
%15 = call i32 @show_line_numbers(i32* %14)
br label %32
16: ; preds = %2
%17 = load i8**, i8*** %7
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i32* @fopen(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %20, i32** %8
%21 = load i32*, i32** %8
%22 = icmp eq i32* %21, null
br i1 %22, label %23, label %28
23: ; preds = %16
%24 = load i8**, i8*** %7
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = call i32 @perror(i8* %26)
br label %31
28: ; preds = %16
%29 = load i32*, i32** %8
%30 = call i32 @show_line_numbers(i32* %29)
br label %31
31: ; preds = %28, %23
br label %32
32: ; preds = %31, %13
%33 = load i32, i32* %3
ret i32 %33
}

LLVM IR (-O2):
@stdin = global i32* null
@.str = [2 x i8] c"r\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 1
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = load i32*, i32** @stdin
%6 = tail call i32 @show_line_numbers(i32* %5)
br label %17
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32* @fopen(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %15
12: ; preds = %7
%13 = load i8*, i8** %8
%14 = tail call i32 @perror(i8* %13)
br label %17
15: ; preds = %7
%16 = tail call i32 @show_line_numbers(i32* %10)
br label %17
17: ; preds = %12, %15, %4
ret i32 0
}