#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 lireligne(char *, int);
int /*<<< orphan*/ putchar(char);
int main(void) {
  int l, i, espace, k, espacement;
  char ligne[1000];
  while ((l = lireligne(ligne, 1000)) > 0) {
    for (i = 0, k = 0; i < l; i++) {
      if (ligne[i] == '\t') {
        espacement = 4 - (k % 4);
        for (espace = 1; espace <= espacement; espace++) {
          putchar(' ');
          k++;
        }
      } else {
        putchar(ligne[i]);
        k++;
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x400,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x400(%rbp),%rdi
mov    $0x3e8,%esi
call   1040 <lireligne@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jle    11fe <main+0xde>
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11f9 <main+0xd9>
movslq -0xc(%rbp),%rax
movsbl -0x400(%rbp,%rax,1),%eax
ff
cmp    $0x9,%eax
jne    11cc <main+0xac>
mov    -0x14(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    $0x4,%eax
sub    %edx,%eax
mov    %eax,-0x18(%rbp)
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x18(%rbp),%eax
jg     11c7 <main+0xa7>
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    119a <main+0x7a>
jmp    11e6 <main+0xc6>
movslq -0xc(%rbp),%rax
movsbl -0x400(%rbp,%rax,1),%edi
ff
call   1030 <putchar@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11eb <main+0xcb>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    115d <main+0x3d>
jmp    1132 <main+0x12>
xor    %eax,%eax
add    $0x400,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x3e8,%rsp
mov    %rsp,%rdi
mov    $0x3e8,%esi
call   1040 <lireligne@plt>
test   %eax,%eax
jle    11c3 <main+0xa3>
mov    %rsp,%r14
jmp    1161 <main+0x41>
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    $0x3e8,%esi
call   1040 <lireligne@plt>
test   %eax,%eax
jle    11c3 <main+0xa3>
mov    %eax,%r15d
xor    %ebx,%ebx
xor    %r12d,%r12d
jmp    1185 <main+0x65>
nopl   0x0(%rax,%rax,1)
movsbl %al,%edi
call   1030 <putchar@plt>
add    $0x1,%r12d
add    $0x1,%rbx
cmp    %r15,%rbx
je     1150 <main+0x30>
mov    (%rsp,%rbx,1),%al
cmp    $0x9,%al
jne    1170 <main+0x50>
lea    0x3(%r12),%eax
test   %r12d,%r12d
cmovns %r12d,%eax
and    $0xfffffffc,%eax
mov    %r12d,%r13d
sub    %eax,%r13d
neg    %eax
mov    %r12d,%ecx
add    $0x4,%r12d
lea    (%rcx,%rax,1),%ebp
add    $0xfffffffc,%ebp
mov    $0x20,%edi
call   1030 <putchar@plt>
inc    %ebp
jne    11b0 <main+0x90>
sub    %r13d,%r12d
jmp    117c <main+0x5c>
xor    %eax,%eax
add    $0x3e8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca [1000 x i8]
store i32 0, i32* %1
br label %8
8: ; preds = %52, %0
%9 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 0
%10 = call i32 @lireligne(i8* %9, i32 1000)
store i32 %10, i32* %2
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %53
12: ; preds = %8
store i32 0, i32* %3
store i32 0, i32* %5
br label %13
13: ; preds = %49, %12
%14 = load i32, i32* %3
%15 = load i32, i32* %2
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %52
17: ; preds = %13
%18 = load i32, i32* %3
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 %19
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 9
br i1 %23, label %24, label %40
24: ; preds = %17
%25 = load i32, i32* %5
%26 = srem i32 %25, 4
%27 = sub nsw i32 4, %26
store i32 %27, i32* %6
store i32 1, i32* %4
br label %28
28: ; preds = %36, %24
%29 = load i32, i32* %4
%30 = load i32, i32* %6
%31 = icmp sle i32 %29, %30
br i1 %31, label %32, label %39
32: ; preds = %28
%33 = call i32 @putchar(i8 signext 32)
%34 = load i32, i32* %5
%35 = add nsw i32 %34, 1
store i32 %35, i32* %5
br label %36
36: ; preds = %32
%37 = load i32, i32* %4
%38 = add nsw i32 %37, 1
store i32 %38, i32* %4
br label %28
39: ; preds = %28
br label %48
40: ; preds = %17
%41 = load i32, i32* %3
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 %42
%44 = load i8, i8* %43
%45 = call i32 @putchar(i8 signext %44)
%46 = load i32, i32* %5
%47 = add nsw i32 %46, 1
store i32 %47, i32* %5
br label %48
48: ; preds = %40, %39
br label %49
49: ; preds = %48
%50 = load i32, i32* %3
%51 = add nsw i32 %50, 1
store i32 %51, i32* %3
br label %13
52: ; preds = %13
br label %8
53: ; preds = %8
ret i32 0
}

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