#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__ getmyline(char *, int);
int /*<<< orphan*/ putchar(char);
int main() {
  char buffer[1024];
  while (getmyline(buffer, 1024) > 0) {
    for (int i = 0; buffer[i] != '\0'; i++) {
      if (buffer[i] == '\t') {
        putchar('    ');
      } else {
        putchar(buffer[i]);
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x410(%rbp),%rdi
mov    $0x400,%esi
call   1040 <getmyline@plt>
cmp    $0x0,%rax
jle    11c8 <main+0xa8>
movl   $0x0,-0x414(%rbp)
movslq -0x414(%rbp),%rax
movsbl -0x410(%rbp,%rax,1),%eax
ff
cmp    $0x0,%eax
je     11c3 <main+0xa3>
movslq -0x414(%rbp),%rax
movsbl -0x410(%rbp,%rax,1),%eax
ff
cmp    $0x9,%eax
jne    1196 <main+0x76>
mov    $0x20,%edi
call   1030 <putchar@plt>
jmp    11aa <main+0x8a>
movslq -0x414(%rbp),%rax
movsbl -0x410(%rbp,%rax,1),%edi
ff
call   1030 <putchar@plt>
jmp    11af <main+0x8f>
mov    -0x414(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x414(%rbp)
jmp    1157 <main+0x37>
jmp    1132 <main+0x12>
xor    %eax,%eax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x408,%rsp
mov    %rsp,%rdi
mov    $0x400,%esi
call   1040 <getmyline@plt>
test   %rax,%rax
jle    1187 <main+0x67>
xor    %ebx,%ebx
mov    %rsp,%r14
jmp    115c <main+0x3c>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsbl %cl,%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
movzbl (%rsp,%rbx,1),%eax
test   %al,%al
je     1170 <main+0x50>
mov    $0x20,%cl
cmp    $0x9,%al
je     1150 <main+0x30>
mov    %eax,%ecx
jmp    1150 <main+0x30>
xchg   %ax,%ax
mov    %r14,%rdi
mov    $0x400,%esi
call   1040 <getmyline@plt>
mov    $0x0,%ebx
test   %rax,%rax
jg     115c <main+0x3c>
xor    %eax,%eax
add    $0x408,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca [1024 x i8]
%3 = alloca i32
store i32 0, i32* %1
br label %4
4: ; preds = %35, %0
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%6 = call i64 @getmyline(i8* %5, i32 1024)
%7 = icmp sgt i64 %6, 0
br i1 %7, label %8, label %36
8: ; preds = %4
store i32 0, i32* %3
br label %9
9: ; preds = %32, %8
%10 = load i32, i32* %3
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 %11
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %35
16: ; preds = %9
%17 = load i32, i32* %3
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 %18
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %21, 9
br i1 %22, label %23, label %25
23: ; preds = %16
%24 = call i32 @putchar(i8 signext 32)
br label %31
25: ; preds = %16
%26 = load i32, i32* %3
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 %27
%29 = load i8, i8* %28
%30 = call i32 @putchar(i8 signext %29)
br label %31
31: ; preds = %25, %23
br label %32
32: ; preds = %31
%33 = load i32, i32* %3
%34 = add nsw i32 %33, 1
store i32 %34, i32* %3
br label %9
35: ; preds = %9
br label %4
36: ; preds = %4
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
%1 = alloca [1024 x i8]
%2 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 0
%3 = call i64 @getmyline(i8* %2, i32 1024)
%4 = icmp sgt i64 %3, 0
br i1 %4, label %8, label %19
5: ; preds = %8
%6 = call i64 @getmyline(i8* %2, i32 1024)
%7 = icmp sgt i64 %6, 0
br i1 %7, label %17, label %19
8: ; preds = %0, %17
%9 = phi i64 [ %18, %17 ], [ 0, %0 ]
%10 = getelementptr inbounds [1024 x i8], [1024 x i8]* %1, i64 0, i64 %9
%11 = load i8, i8* %10
switch i8 %11, label %12 [
i8 0, label %5
i8 9, label %13
]
12: ; preds = %8
br label %13
13: ; preds = %8, %12
%14 = phi i8 [ %11, %12 ], [ 32, %8 ]
%15 = call i32 @putchar(i8 signext %14)
%16 = add nuw i64 %9, 1
br label %17
17: ; preds = %13, %5
%18 = phi i64 [ %16, %13 ], [ 0, %5 ]
br label %8
19: ; preds = %5, %0
ret i32 0
}