#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 atoi(char *);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ wait(int);
int main(int argc, char *argv[]) {
  int n, sec;
  char *a = "Aquest programa funciona";
  sec = (argc == 2) ? atoi(argv[1]) : 1;
  for (; *a; ++a) {
    wait(sec);
    printf("%c", *a);
    fflush(stdout);
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xea3(%rip),%rax
mov    %rax,-0x20(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    1180 <main+0x40>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x24(%rbp)
jmp    118d <main+0x4d>
mov    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    118d <main+0x4d>
mov    -0x24(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x20(%rbp),%rax
cmpb   $0x0,(%rax)
je     11dc <main+0x9c>
mov    -0x18(%rbp),%edi
call   1060 <wait@plt>
mov    -0x20(%rbp),%rax
movsbl (%rax),%esi
lea    0xe63(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e1c(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1193 <main+0x53>
lea    0xe39(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    $0x1,%ebp
cmp    $0x2,%edi
jne    115c <main+0x1c>
mov    0x8(%rsi),%rdi
call   1050 <atoi@plt>
mov    %eax,%ebp
xor    %ebx,%ebx
lea    0xe9b(%rip),%r14
mov    0x2e74(%rip),%r15
nopl   0x0(%rax)
mov    %ebp,%edi
call   1060 <wait@plt>
movsbl (%rbx,%r14,1),%edi
call   1030 <putchar@plt>
mov    (%r15),%edi
call   1040 <fflush@plt>
add    $0x1,%rbx
cmp    $0x18,%rbx
jne    1170 <main+0x30>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [25 x i8] c"Aquest programa funciona\00"
@.str.1 = [3 x i8] c"%c\00"
@stdout = global i32 0
@.str.2 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8** %8
%9 = load i32, i32* %4
%10 = icmp eq i32 %9, 2
br i1 %10, label %11, label %16
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i32 @atoi(i8* %14)
br label %17
16: ; preds = %2
br label %17
17: ; preds = %16, %11
%18 = phi i32 [ %15, %11 ], [ 1, %16 ]
store i32 %18, i32* %7
br label %19
19: ; preds = %32, %17
%20 = load i8*, i8** %8
%21 = load i8, i8* %20
%22 = icmp ne i8 %21, 0
br i1 %22, label %23, label %35
23: ; preds = %19
%24 = load i32, i32* %7
%25 = call i32 @wait(i32 %24)
%26 = load i8*, i8** %8
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %28)
%30 = load i32, i32* @stdout
%31 = call i32 @fflush(i32 %30)
br label %32
32: ; preds = %23
%33 = load i8*, i8** %8
%34 = getelementptr inbounds i8, i8* %33, i32 1
store i8* %34, i8** %8
br label %19
35: ; preds = %19
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [25 x i8] c"Aquest programa funciona\00"
@stdout = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %4, label %8
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32 @atoi(i8* %6)
br label %8
8: ; preds = %2, %4
%9 = phi i32 [ %7, %4 ], [ 1, %2 ]
br label %10
10: ; preds = %8, %10
%11 = phi i8* [ getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), %8 ], [ %18, %10 ]
%12 = tail call i32 @wait(i32 %9)
%13 = load i8, i8* %11
%14 = sext i8 %13 to i32
%15 = tail call i32 @putchar(i32 %14)
%16 = load i32, i32* @stdout
%17 = tail call i32 @fflush(i32 %16)
%18 = getelementptr inbounds i8, i8* %11, i64 1
%19 = icmp eq i8* %18, getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 24)
br i1 %19, label %20, label %10
20: ; preds = %10
%21 = tail call i32 @putchar(i32 10)
ret i32 0
}