#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*/ cprint(int, int, int /*<<< orphan*/, int, char *);
int /*<<< orphan*/ gets(char *);
int display() {
  char str[100];
  int i;
  for (i = 0; i < 25 * 80; i++)
    cprint(i / 80, i % 80, 0, i, "a");
  gets(str);
  return 0;
}


x86 assembly (clang, -O0):
<display>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x74(%rbp)
cmpl   $0x7d0,-0x74(%rbp)
jge    1178 <display+0x58>
mov    -0x74(%rbp),%eax
mov    $0x50,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
mov    -0x74(%rbp),%eax
mov    $0x50,%ecx
cltd
idiv   %ecx
mov    %edx,%esi
mov    -0x74(%rbp),%ecx
xor    %edx,%edx
lea    0xe9b(%rip),%r8
call   1030 <cprint@plt>
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
jmp    1132 <display+0x12>
lea    -0x70(%rbp),%rdi
call   1040 <gets@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<display>:
push   %r15
push   %r14
push   %rbx
sub    $0x70,%rsp
xor    %ebx,%ebx
mov    $0xcccccccd,%r15d
lea    0xec8(%rip),%r14
nopl   0x0(%rax,%rax,1)
mov    %ebx,%eax
imul   %r15,%rax
shr    $0x26,%rax
shl    $0x4,%eax
lea    (%rax,%rax,4),%eax
movzwl %bx,%ecx
imul   $0xcccd,%ecx,%edi
shr    $0x16,%edi
mov    %ebx,%esi
sub    %eax,%esi
xor    %edx,%edx
mov    %ebx,%ecx
mov    %r14,%r8
call   1030 <cprint@plt>
add    $0x1,%ebx
cmp    $0x7d0,%ebx
jne    1140 <display+0x20>
mov    %rsp,%rdi
call   1040 <gets@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c"a\00"
define i32 @display() {
%1 = alloca [100 x i8]
%2 = alloca i32
store i32 0, i32* %2
br label %3
3: ; preds = %13, %0
%4 = load i32, i32* %2
%5 = icmp slt i32 %4, 2000
br i1 %5, label %6, label %16
6: ; preds = %3
%7 = load i32, i32* %2
%8 = sdiv i32 %7, 80
%9 = load i32, i32* %2
%10 = srem i32 %9, 80
%11 = load i32, i32* %2
%12 = call i32 @cprint(i32 %8, i32 %10, i32 0, i32 %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %13
13: ; preds = %6
%14 = load i32, i32* %2
%15 = add nsw i32 %14, 1
store i32 %15, i32* %2
br label %3
16: ; preds = %3
%17 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%18 = call i32 @gets(i8* %17)
ret i32 0
}

LLVM IR (-O2):
@.str = [2 x i8] c"a\00"
define i32 @display() {
%1 = alloca [100 x i8]
%2 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
br label %3
3: ; preds = %0, %3
%4 = phi i32 [ 0, %0 ], [ %11, %3 ]
%5 = trunc i32 %4 to i16
%6 = udiv i16 %5, 80
%7 = zext i16 %6 to i32
%8 = urem i16 %5, 80
%9 = zext i16 %8 to i32
%10 = tail call i32 @cprint(i32 %7, i32 %9, i32 0, i32 %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%11 = add nuw nsw i32 %4, 1
%12 = icmp eq i32 %11, 2000
br i1 %12, label %13, label %3
13: ; preds = %3
%14 = call i32 @gets(i8* %2)
ret i32 0
}