#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 EOF;
int getchar();
int /*<<< orphan*/ putchar(char);
void detab(int spaces) {
  int character, i;
  while ((character = getchar()) != EOF) {
    if (character != '\t') {
      putchar(character);
    } else {
      for (i = 0; i < spaces; i++) {
        putchar(' ');
      }
    }
  }
}


x86 assembly (clang, -O0):
<detab>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x8(%rbp)
mov    0x2eac(%rip),%rcx
cmp    (%rcx),%eax
je     1193 <detab+0x73>
cmpl   $0x9,-0x8(%rbp)
je     115e <detab+0x3e>
mov    -0x8(%rbp),%eax
movsbl %al,%edi
call   1030 <putchar@plt>
jmp    118e <detab+0x6e>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1189 <detab+0x69>
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1165 <detab+0x45>
jmp    118e <detab+0x6e>
jmp    112b <detab+0xb>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<detab>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%ebx
xor    %eax,%eax
call   1040 <getchar@plt>
mov    0x2eb4(%rip),%r14
jmp    114f <detab+0x2f>
cs nopw 0x0(%rax,%rax,1)
movsbl %al,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    (%r14),%eax
je     1171 <detab+0x51>
cmp    $0x9,%eax
jne    1140 <detab+0x20>
mov    %ebx,%ebp
test   %ebx,%ebx
jle    1148 <detab+0x28>
nop
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jne    1160 <detab+0x40>
jmp    1148 <detab+0x28>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@EOF = global i32 0
define void @detab(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %2
br label %5
5: ; preds = %27, %1
%6 = call i32 (...) @getchar()
store i32 %6, i32* %3
%7 = load i32, i32* @EOF
%8 = icmp ne i32 %6, %7
br i1 %8, label %9, label %28
9: ; preds = %5
%10 = load i32, i32* %3
%11 = icmp ne i32 %10, 9
br i1 %11, label %12, label %16
12: ; preds = %9
%13 = load i32, i32* %3
%14 = trunc i32 %13 to i8
%15 = call i32 @putchar(i8 signext %14)
br label %27
16: ; preds = %9
store i32 0, i32* %4
br label %17
17: ; preds = %23, %16
%18 = load i32, i32* %4
%19 = load i32, i32* %2
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %26
21: ; preds = %17
%22 = call i32 @putchar(i8 signext 32)
br label %23
23: ; preds = %21
%24 = load i32, i32* %4
%25 = add nsw i32 %24, 1
store i32 %25, i32* %4
br label %17
26: ; preds = %17
br label %27
27: ; preds = %26, %12
br label %5
28: ; preds = %5
ret void
}

LLVM IR (-O2):
@EOF = global i32 0
define void @detab(i32 %0) {
%2 = tail call i32 (...) @getchar()
%3 = load i32, i32* @EOF
%4 = icmp eq i32 %2, %3
br i1 %4, label %23, label %5
5: ; preds = %1
%6 = icmp sgt i32 %0, 0
br label %7
7: ; preds = %5, %19
%8 = phi i32 [ %2, %5 ], [ %20, %19 ]
%9 = icmp eq i32 %8, 9
br i1 %9, label %10, label %11
10: ; preds = %7
br i1 %6, label %14, label %19
11: ; preds = %7
%12 = trunc i32 %8 to i8
%13 = tail call i32 @putchar(i8 signext %12)
br label %19
14: ; preds = %10, %14
%15 = phi i32 [ %17, %14 ], [ 0, %10 ]
%16 = tail call i32 @putchar(i8 signext 32)
%17 = add nuw nsw i32 %15, 1
%18 = icmp eq i32 %17, %0
br i1 %18, label %19, label %14
19: ; preds = %14, %10, %11
%20 = tail call i32 (...) @getchar()
%21 = load i32, i32* @EOF
%22 = icmp eq i32 %20, %21
br i1 %22, label %23, label %7
23: ; preds = %19, %1
ret void
}