#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 /*<<< orphan*/ printf(char *, char *);
int readline(char *, int);
scalar_t__ strstr(char *, char *);
int test();
int main(int argc, char *argv[]) {
  int len;
  char line[80 + 1];
  if (strstr(argv[0], "test"))
    return test();
  while ((len = readline(line, 80)) > 0) {
    printf("%s\n", line);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe9c(%rip),%rsi
call   1050 <strstr@plt>
cmp    $0x0,%rax
je     1182 <main+0x42>
mov    $0x0,%al
call   1060 <test@plt>
mov    %eax,-0x4(%rbp)
jmp    11bd <main+0x7d>
jmp    1187 <main+0x47>
lea    -0x70(%rbp),%rdi
mov    $0x50,%esi
call   1040 <readline@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jle    11b6 <main+0x76>
lea    -0x70(%rbp),%rsi
lea    0xe59(%rip),%rdi
call   1030 <printf@plt>
jmp    1187 <main+0x47>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x58,%rsp
mov    (%rsi),%rdi
lea    0xeaf(%rip),%rsi
call   1050 <strstr@plt>
test   %rax,%rax
je     1169 <main+0x29>
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r14
jmp    1060 <test@plt>
mov    %rsp,%rdi
mov    $0x50,%esi
call   1040 <readline@plt>
test   %eax,%eax
jle    11ac <main+0x6c>
lea    0xe84(%rip),%r14
mov    %rsp,%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x50,%esi
call   1040 <readline@plt>
test   %eax,%eax
jg     1190 <main+0x50>
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [5 x i8] c"test\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [81 x i8]
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, i64 0
%10 = load i8*, i8** %9
%11 = call i64 @strstr(i8* %10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %2
%14 = call i32 (...) @test()
store i32 %14, i32* %3
br label %24
15: ; preds = %2
br label %16
16: ; preds = %20, %15
%17 = getelementptr inbounds [81 x i8], [81 x i8]* %7, i64 0, i64 0
%18 = call i32 @readline(i8* %17, i32 80)
store i32 %18, i32* %6
%19 = icmp sgt i32 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %16
%21 = getelementptr inbounds [81 x i8], [81 x i8]* %7, i64 0, i64 0
%22 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %21)
br label %16
23: ; preds = %16
store i32 0, i32* %3
br label %24
24: ; preds = %23, %13
%25 = load i32, i32* %3
ret i32 %25
}

LLVM IR (-O2):
@.str = [5 x i8] c"test\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [81 x i8]
%4 = getelementptr inbounds [81 x i8], [81 x i8]* %3, i64 0, i64 0
%5 = load i8*, i8** %1
%6 = tail call i64 @strstr(i8* %5, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = call i32 @readline(i8* %4, i32 80)
%10 = icmp sgt i32 %9, 0
br i1 %10, label %13, label %17
11: ; preds = %2
%12 = tail call i32 (...) @test()
br label %17
13: ; preds = %8, %13
%14 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%15 = call i32 @readline(i8* %4, i32 80)
%16 = icmp sgt i32 %15, 0
br i1 %16, label %13, label %17
17: ; preds = %13, %8, %11
%18 = phi i32 [ %12, %11 ], [ 0, %8 ], [ 0, %13 ]
ret i32 %18
}