#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 */
char *diceroll(int);
char *fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *, char *);
int /*<<< orphan*/ stdin;
int main(void) {
  char *cp, tmp[20];
  int i;
  i = 0;
  while (i >= 0 && (cp = fgets(tmp, sizeof tmp, stdin)) != NULL) {
    printf("%s %s", diceroll(i), tmp);
    i++;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x34(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x34(%rbp)
mov    %al,-0x35(%rbp)
jl     117a <main+0x4a>
lea    -0x30(%rbp),%rdi
mov    0x2e88(%rip),%rax
mov    (%rax),%edx
mov    $0x14,%esi
call   1040 <fgets@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
setne  %al
mov    %al,-0x35(%rbp)
mov    -0x35(%rbp),%al
test   $0x1,%al
jne    118a <main+0x5a>
jmp    11b3 <main+0x83>
mov    -0x34(%rbp),%edi
call   1050 <diceroll@plt>
mov    %rax,%rsi
lea    -0x30(%rbp),%rdx
lea    0xe60(%rip),%rdi
call   1030 <printf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1146 <main+0x16>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    0x2ea6(%rip),%r12
mov    (%r12),%edx
mov    %rsp,%rdi
mov    $0x14,%esi
call   1040 <fgets@plt>
test   %rax,%rax
je     119e <main+0x6e>
xor    %ebx,%ebx
lea    0xe9f(%rip),%r14
mov    %rsp,%r15
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %ebx,%edi
call   1050 <diceroll@plt>
mov    %r14,%rdi
mov    %rax,%rsi
mov    %r15,%rdx
call   1030 <printf@plt>
add    $0x1,%ebx
mov    (%r12),%edx
mov    %r15,%rdi
mov    $0x14,%esi
call   1040 <fgets@plt>
test   %rax,%rax
jne    1170 <main+0x40>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stdin = global i32 0
@.str = [6 x i8] c"%s %s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca [20 x i8]
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %4
br label %5
5: ; preds = %15, %0
%6 = load i32, i32* %4
%7 = icmp sge i32 %6, 0
br i1 %7, label %8, label %13
8: ; preds = %5
%9 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%10 = load i32, i32* @stdin
%11 = call i8* @fgets(i8* %9, i32 20, i32 %10)
store i8* %11, i8** %2
%12 = icmp ne i8* %11, null
br label %13
13: ; preds = %8, %5
%14 = phi i1 [ false, %5 ], [ %12, %8 ]
br i1 %14, label %15, label %22
15: ; preds = %13
%16 = load i32, i32* %4
%17 = call i8* @diceroll(i32 %16)
%18 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%19 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %17, i8* %18)
%20 = load i32, i32* %4
%21 = add nsw i32 %20, 1
store i32 %21, i32* %4
br label %5
22: ; preds = %13
ret i32 0
}

LLVM IR (-O2):
@stdin = global i32 0
@.str = [6 x i8] c"%s %s\00"
define i32 @main() {
%1 = alloca [20 x i8]
%2 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%3 = load i32, i32* @stdin
%4 = call i8* @fgets(i8* %2, i32 20, i32 %3)
%5 = icmp eq i8* %4, null
br i1 %5, label %14, label %6
6: ; preds = %0, %6
%7 = phi i32 [ %10, %6 ], [ 0, %0 ]
%8 = call i8* @diceroll(i32 %7)
%9 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %8, i8* %2)
%10 = add nuw nsw i32 %7, 1
%11 = load i32, i32* @stdin
%12 = call i8* @fgets(i8* %2, i32 20, i32 %11)
%13 = icmp eq i8* %12, null
br i1 %13, label %14, label %6
14: ; preds = %6, %0
ret i32 0
}