#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 /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ usleep(int);
void long_printf(const char *str) {
  for (char *iter = (char *)str; *iter; iter++) {
    printf("%c", *iter);
    fflush(stdout);
    usleep(500000);
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<long_printf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     118f <long_printf+0x5f>
mov    -0x10(%rbp),%rax
movsbl (%rax),%esi
lea    0xea1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e73(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
mov    $0x7a120,%edi
call   1050 <usleep@plt>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1144 <long_printf+0x14>
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<long_printf>:
push   %r14
push   %rbx
push   %rax
mov    (%rdi),%al
test   %al,%al
je     1175 <long_printf+0x45>
mov    %rdi,%rbx
add    $0x1,%rbx
mov    0x2e98(%rip),%r14
nopl   0x0(%rax,%rax,1)
movsbl %al,%edi
call   1030 <putchar@plt>
mov    (%r14),%edi
call   1040 <fflush@plt>
mov    $0x7a120,%edi
call   1050 <usleep@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1150 <long_printf+0x20>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"%c\00"
@stdout = global i32 0
@.str.1 = [2 x i8] c"\0A\00"
define void @long_printf(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
store i8* %0, i8** %2
%4 = load i8*, i8** %2
store i8* %4, i8** %3
br label %5
5: ; preds = %17, %1
%6 = load i8*, i8** %3
%7 = load i8, i8* %6
%8 = icmp ne i8 %7, 0
br i1 %8, label %9, label %20
9: ; preds = %5
%10 = load i8*, i8** %3
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = load i32, i32* @stdout
%15 = call i32 @fflush(i32 %14)
%16 = call i32 @usleep(i32 500000)
br label %17
17: ; preds = %9
%18 = load i8*, i8** %3
%19 = getelementptr inbounds i8, i8* %18, i32 1
store i8* %19, i8** %3
br label %5
20: ; preds = %5
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@stdout = global i32 0
define void @long_printf(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %4, label %6
4: ; preds = %6, %1
%5 = tail call i32 @putchar(i32 10)
ret void
6: ; preds = %1, %6
%7 = phi i8 [ %15, %6 ], [ %2, %1 ]
%8 = phi i8* [ %14, %6 ], [ %0, %1 ]
%9 = sext i8 %7 to i32
%10 = tail call i32 @putchar(i32 %9)
%11 = load i32, i32* @stdout
%12 = tail call i32 @fflush(i32 %11)
%13 = tail call i32 @usleep(i32 500000)
%14 = getelementptr inbounds i8, i8* %8, i64 1
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 0
br i1 %16, label %4, label %6
}