#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 */
int cat(char *);
int main(int argc, char **argv) {
  if (argc <= 1)
    return cat("/dev/stdin");
  int i = 1;
  while (i < argc)
    if (cat(argv[i++]))
      return 1;
  return 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)
cmpl   $0x1,-0x8(%rbp)
jg     1144 <main+0x34>
lea    0xec9(%rip),%rdi
call   1030 <cat@plt>
mov    %eax,-0x4(%rbp)
jmp    1193 <main+0x83>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    118c <main+0x7c>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x14(%rbp)
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <cat@plt>
cmp    $0x0,%eax
je     1187 <main+0x77>
movl   $0x1,-0x4(%rbp)
jmp    1193 <main+0x83>
jmp    114b <main+0x3b>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
cmp    $0x2,%edi
jge    112b <main+0x1b>
lea    0xedf(%rip),%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <cat@plt>
mov    %rsi,%r14
mov    %edi,%r15d
mov    $0x1,%ebx
cs nopw 0x0(%rax,%rax,1)
cmp    %rbx,%r15
je     115d <main+0x4d>
mov    (%r14,%rbx,8),%rdi
add    $0x1,%rbx
call   1030 <cat@plt>
test   %eax,%eax
je     1140 <main+0x30>
mov    $0x1,%eax
jmp    115f <main+0x4f>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [11 x i8] c"/dev/stdin\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp sle i32 %7, 1
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = call i32 @cat(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
store i32 %10, i32* %3
br label %28
11: ; preds = %2
store i32 1, i32* %6
br label %12
12: ; preds = %26, %11
%13 = load i32, i32* %6
%14 = load i32, i32* %4
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %27
16: ; preds = %12
%17 = load i8**, i8*** %5
%18 = load i32, i32* %6
%19 = add nsw i32 %18, 1
store i32 %19, i32* %6
%20 = sext i32 %18 to i64
%21 = getelementptr inbounds i8*, i8** %17, i64 %20
%22 = load i8*, i8** %21
%23 = call i32 @cat(i8* %22)
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %16
store i32 1, i32* %3
br label %28
26: ; preds = %16
br label %12
27: ; preds = %12
store i32 0, i32* %3
br label %28
28: ; preds = %27, %25, %9
%29 = load i32, i32* %3
ret i32 %29
}

LLVM IR (-O2):
@.str = [11 x i8] c"/dev/stdin\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = zext i32 %0 to i64
br label %8
6: ; preds = %2
%7 = tail call i32 @cat(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
br label %17
8: ; preds = %4, %11
%9 = phi i64 [ 1, %4 ], [ %12, %11 ]
%10 = icmp eq i64 %9, %5
br i1 %10, label %17, label %11
11: ; preds = %8
%12 = add nuw nsw i64 %9, 1
%13 = getelementptr inbounds i8*, i8** %1, i64 %9
%14 = load i8*, i8** %13
%15 = tail call i32 @cat(i8* %14)
%16 = icmp eq i32 %15, 0
br i1 %16, label %8, label %17
17: ; preds = %11, %8, %6
%18 = phi i32 [ %7, %6 ], [ 0, %8 ], [ 1, %11 ]
ret i32 %18
}