#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*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ scan_file(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ *stdin;
int main(int argc, char *argv[]) {
  char *n;
  argv++;
  if (*argv == NULL)
    scan_file(stdin, "<stdin>");
  else
    while ((n = *argv++) != NULL) {
      FILE *fp = fopen(n, "r");
      if (fp == NULL) {
        perror(n);
        exit(1);
      }
      scan_file(fp, n);
      fclose(fp);
    }
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
jne    119b <main+0x4b>
mov    0x2e61(%rip),%rax
mov    (%rax),%rdi
lea    0xe6f(%rip),%rsi
call   1070 <scan_file@plt>
jmp    1212 <main+0xc2>
jmp    11a0 <main+0x50>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     120d <main+0xbd>
mov    -0x18(%rbp),%rdi
lea    0xe3d(%rip),%rsi
call   1040 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11f2 <main+0xa2>
mov    -0x18(%rbp),%rdi
call   1050 <perror@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1070 <scan_file@plt>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
jmp    11a0 <main+0x50>
jmp    1212 <main+0xc2>
xor    %edi,%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    0x8(%rsi),%r14
test   %r14,%r14
jne    117e <main+0x2e>
mov    0x2e80(%rip),%rax
mov    (%rax),%rdi
lea    0xe8e(%rip),%rsi
call   1070 <scan_file@plt>
xor    %edi,%edi
call   1060 <exit@plt>
mov    %rsi,%r12
add    $0x10,%r12
lea    0xe7c(%rip),%r15
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <fopen@plt>
test   %rax,%rax
je     11ca <main+0x7a>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
call   1070 <scan_file@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
mov    (%r12),%r14
add    $0x8,%r12
test   %r14,%r14
jne    1190 <main+0x40>
xor    %edi,%edi
call   1060 <exit@plt>
mov    %r14,%rdi
call   1050 <perror@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@stdin = global i32* null
@.str = [8 x i8] c"<stdin>\00"
@.str.1 = [2 x i8] c"r\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i8**, i8*** %5
%9 = getelementptr inbounds i8*, i8** %8, i32 1
store i8** %9, i8*** %5
%10 = load i8**, i8*** %5
%11 = load i8*, i8** %10
%12 = icmp eq i8* %11, null
br i1 %12, label %13, label %16
13: ; preds = %2
%14 = load i32*, i32** @stdin
%15 = call i32 @scan_file(i32* %14, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
br label %38
16: ; preds = %2
br label %17
17: ; preds = %31, %16
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i32 1
store i8** %19, i8*** %5
%20 = load i8*, i8** %18
store i8* %20, i8** %6
%21 = icmp ne i8* %20, null
br i1 %21, label %22, label %37
22: ; preds = %17
%23 = load i8*, i8** %6
%24 = call i32* @fopen(i8* %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %24, i32** %7
%25 = load i32*, i32** %7
%26 = icmp eq i32* %25, null
br i1 %26, label %27, label %31
27: ; preds = %22
%28 = load i8*, i8** %6
%29 = call i32 @perror(i8* %28)
%30 = call i32 @exit(i32 1)
unreachable
31: ; preds = %22
%32 = load i32*, i32** %7
%33 = load i8*, i8** %6
%34 = call i32 @scan_file(i32* %32, i8* %33)
%35 = load i32*, i32** %7
%36 = call i32 @fclose(i32* %35)
br label %17
37: ; preds = %17
br label %38
38: ; preds = %37, %13
%39 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@stdin = global i32* null
@.str = [8 x i8] c"<stdin>\00"
@.str.1 = [2 x i8] c"r\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = icmp eq i8* %4, null
br i1 %5, label %8, label %6
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 2
br label %11
8: ; preds = %2
%9 = load i32*, i32** @stdin
%10 = tail call i32 @scan_file(i32* %9, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
br label %25
11: ; preds = %6, %19
%12 = phi i8** [ %7, %6 ], [ %23, %19 ]
%13 = phi i8* [ %4, %6 ], [ %22, %19 ]
%14 = tail call i32* @fopen(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %19
16: ; preds = %11
%17 = tail call i32 @perror(i8* %13)
%18 = tail call i32 @exit(i32 1)
unreachable
19: ; preds = %11
%20 = tail call i32 @scan_file(i32* %14, i8* %13)
%21 = tail call i32 @fclose(i32* %14)
%22 = load i8*, i8** %12
%23 = getelementptr inbounds i8*, i8** %12, i64 1
%24 = icmp eq i8* %22, null
br i1 %24, label %25, label %11
25: ; preds = %19, %8
%26 = tail call i32 @exit(i32 0)
unreachable
}