#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 /*<<< orphan*/ putchar(char);
void c(int times) {
  int x = 0;
  int y = 0;
  printf("\nI'm having fun now!\n");
  while (x <= times) {
    printf("Ha ha!\n");
    while (y >= 0) {
      putchar(' ');
      y--;
    }
    x++;
    y = x;
  }
}


x86 assembly (clang, -O0):
<c>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xec0(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     1193 <c+0x73>
lea    0xebe(%rip),%rdi
call   1040 <printf@plt>
cmpl   $0x0,-0xc(%rbp)
jl     117f <c+0x5f>
mov    $0x20,%edi
call   1030 <putchar@plt>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    115d <c+0x3d>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    1145 <c+0x25>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<c>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edi,%r15d
lea    0xece(%rip),%rdi
call   1040 <puts@plt>
test   %r15d,%r15d
js     1181 <c+0x61>
xor    %r12d,%r12d
mov    $0x1,%ebx
lea    0xeca(%rip),%r14
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1040 <puts@plt>
mov    %ebx,%ebp
nopw   0x0(%rax,%rax,1)
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
test   %ebp,%ebp
jg     1160 <c+0x40>
lea    0x1(%r12),%eax
add    $0x1,%ebx
cmp    %r15d,%r12d
mov    %eax,%r12d
jne    1150 <c+0x30>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [22 x i8] c"\0AI'm having fun now!\0A\00"
@.str.1 = [8 x i8] c"Ha ha!\0A\00"
define void @c(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %4
%5 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %19, %1
%7 = load i32, i32* %3
%8 = load i32, i32* %2
%9 = icmp sle i32 %7, %8
br i1 %9, label %10, label %23
10: ; preds = %6
%11 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
br label %12
12: ; preds = %15, %10
%13 = load i32, i32* %4
%14 = icmp sge i32 %13, 0
br i1 %14, label %15, label %19
15: ; preds = %12
%16 = call i32 @putchar(i8 signext 32)
%17 = load i32, i32* %4
%18 = add nsw i32 %17, -1
store i32 %18, i32* %4
br label %12
19: ; preds = %12
%20 = load i32, i32* %3
%21 = add nsw i32 %20, 1
store i32 %21, i32* %3
%22 = load i32, i32* %3
store i32 %22, i32* %4
br label %6
23: ; preds = %6
ret void
}

LLVM IR (-O2):
@str = [21 x i8] c"\0AI'm having fun now!\00"
@str.2 = [7 x i8] c"Ha ha!\00"
define void @c(i32 %0) {
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
%3 = icmp slt i32 %0, 0
br i1 %3, label %15, label %4
4: ; preds = %1, %12
%5 = phi i32 [ %13, %12 ], [ 0, %1 ]
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str.2, i64 0, i64 0))
br label %7
7: ; preds = %4, %7
%8 = phi i32 [ %10, %7 ], [ %5, %4 ]
%9 = tail call i32 @putchar(i8 signext 32)
%10 = add nsw i32 %8, -1
%11 = icmp sgt i32 %8, 0
br i1 %11, label %7, label %12
12: ; preds = %7
%13 = add nuw i32 %5, 1
%14 = icmp eq i32 %5, %0
br i1 %14, label %15, label %4
15: ; preds = %12, %1
ret void
}