#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*/ printf(char *, ...);
int strlen(char *);
int main() {
  char str[] = "HOLA";
  int n;
  n = 0;
  while (n < strlen(str)) {
    printf("%c", str[n]);
    n++;
  }
  printf("\n");
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xecb(%rip),%eax
mov    %eax,-0x9(%rbp)
mov    0xec6(%rip),%al
mov    %al,-0x5(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
lea    -0x9(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
cmp    %ecx,%eax
jge    1189 <main+0x69>
movslq -0x10(%rbp),%rax
movsbl -0x9(%rbp,%rax,1),%esi
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1148 <main+0x28>
lea    0xe78(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
movb   $0x0,0x4(%rsp)
movl   $0x414c4f48,(%rsp)
mov    %rsp,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    116c <main+0x4c>
xor    %ebx,%ebx
mov    %rsp,%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsbl (%rsp,%rbx,1),%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
mov    %r14,%rdi
call   1040 <strlen@plt>
cltq
cmp    %rax,%rbx
jl     1150 <main+0x30>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.str = [5 x i8] c"HOLA\00"
@.str = [3 x i8] c"%c\00"
@.str.1 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [5 x i8]
%3 = alloca i32
store i32 0, i32* %1
%4 = bitcast [5 x i8]* %2 to i8*
store i32 0, i32* %3
br label %5
5: ; preds = %10, %0
%6 = load i32, i32* %3
%7 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%8 = call i32 @strlen(i8* %7)
%9 = icmp slt i32 %6, %8
br i1 %9, label %10, label %19
10: ; preds = %5
%11 = load i32, i32* %3
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 %12
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = load i32, i32* %3
%18 = add nsw i32 %17, 1
store i32 %18, i32* %3
br label %5
19: ; preds = %5
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@__const.main.str = [5 x i8] c"HOLA\00"
define i32 @main() {
%1 = alloca [5 x i8]
%2 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%3 = call i32 @strlen(i8* %2)
%4 = icmp sgt i32 %3, 0
br i1 %4, label %5, label %15
5: ; preds = %0, %5
%6 = phi i64 [ %11, %5 ], [ 0, %0 ]
%7 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 %6
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
%10 = call i32 @putchar(i32 %9)
%11 = add nuw nsw i64 %6, 1
%12 = call i32 @strlen(i8* %2)
%13 = sext i32 %12 to i64
%14 = icmp slt i64 %11, %13
br i1 %14, label %5, label %15
15: ; preds = %5, %0
%16 = call i32 @putchar(i32 10)
ret i32 0
}