#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 */
scalar_t__ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ stdin;
int main(int argc, char *argv[]) {
  void colorize(char *string);
  if (argc == 1) {
    char str[1024];
    while (fgets(str, sizeof str, stdin)) {
      colorize(str);
    }
  } else
    colorize(argv[1]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    1182 <main+0x62>
jmp    1148 <main+0x28>
lea    -0x410(%rbp),%rdi
mov    0x2e92(%rip),%rax
mov    (%rax),%edx
mov    $0x400,%esi
call   1030 <fgets@plt>
cmp    $0x0,%rax
je     117d <main+0x5d>
lea    -0x410(%rbp),%rdi
call   1040 <colorize@plt>
jmp    1148 <main+0x28>
jmp    118f <main+0x6f>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <colorize@plt>
xor    %eax,%eax
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x408,%rsp
cmp    $0x1,%edi
jne    116f <main+0x4f>
mov    0x2eb2(%rip),%r14
mov    (%r14),%edx
mov    %rsp,%rdi
mov    $0x400,%esi
call   1030 <fgets@plt>
test   %rax,%rax
je     1178 <main+0x58>
mov    %rsp,%rbx
xchg   %ax,%ax
mov    %rbx,%rdi
call   1040 <colorize@plt>
mov    (%r14),%edx
mov    %rbx,%rdi
mov    $0x400,%esi
call   1030 <fgets@plt>
test   %rax,%rax
jne    1150 <main+0x30>
jmp    1178 <main+0x58>
mov    0x8(%rsi),%rdi
call   1040 <colorize@plt>
xor    %eax,%eax
add    $0x408,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@stdin = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [1024 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp eq i32 %7, 1
br i1 %8, label %9, label %18
9: ; preds = %2
br label %10
10: ; preds = %15, %9
%11 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%12 = load i32, i32* @stdin
%13 = call i64 @fgets(i8* %11, i32 1024, i32 %12)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %10
%16 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
br label %10
17: ; preds = %10
br label %22
18: ; preds = %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
br label %22
22: ; preds = %18, %17
ret i32 0
}

LLVM IR (-O2):
@stdin = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1024 x i8]
%4 = icmp eq i32 %0, 1
br i1 %4, label %5, label %15
5: ; preds = %2
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%7 = load i32, i32* @stdin
%8 = call i64 @fgets(i8* %6, i32 1024, i32 %7)
%9 = icmp eq i64 %8, 0
br i1 %9, label %14, label %10
10: ; preds = %5, %10
%11 = load i32, i32* @stdin
%12 = call i64 @fgets(i8* %6, i32 1024, i32 %11)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %10
14: ; preds = %10, %5
br label %18
15: ; preds = %2
%16 = getelementptr inbounds i8*, i8** %1, i64 1
%17 = load i8*, i8** %16
tail call void @colorize(i8* %17)
br label %18
18: ; preds = %15, %14
ret i32 0
}