#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, int, int, int);
int rand();
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ stdout;
int main(int argc, char **argv) {
  int astep = 0, bstep = 0, abutton = 0, bbutton = 0;
  int nstep = 20;
  for (;;) {
    astep = rand() % nstep;
    bstep = rand() % nstep;
    abutton = rand() % 2;
    bbutton = rand() % 2;
    printf("%i %i %i %i\n", astep, bstep, abutton, bbutton);
    fflush(stdout);
    sleep(10);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x14,-0x24(%rbp)
mov    $0x0,%al
call   1060 <rand@plt>
cltd
idivl  -0x24(%rbp)
mov    %edx,-0x14(%rbp)
mov    $0x0,%al
call   1060 <rand@plt>
cltd
idivl  -0x24(%rbp)
mov    %edx,-0x18(%rbp)
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %edx,-0x1c(%rbp)
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %edx,-0x20(%rbp)
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x1c(%rbp),%ecx
mov    -0x20(%rbp),%r8d
lea    0xe33(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e07(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
mov    $0xa,%edi
call   1050 <sleep@plt>
jmp    1179 <main+0x39>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
lea    0xeb1(%rip),%r14
mov    0x2e8a(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   1060 <rand@plt>
movslq %eax,%r15
imul   $0x66666667,%r15,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x23,%rax
add    %ecx,%eax
shl    $0x2,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%r15d
xor    %eax,%eax
call   1060 <rand@plt>
movslq %eax,%rbx
imul   $0x66666667,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x23,%rax
add    %ecx,%eax
shl    $0x2,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%ebx
xor    %eax,%eax
call   1060 <rand@plt>
mov    %eax,%ebp
shr    $0x1f,%eax
add    %ebp,%eax
and    $0xfffffffe,%eax
sub    %eax,%ebp
xor    %eax,%eax
call   1060 <rand@plt>
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
and    $0xfffffffe,%ecx
sub    %ecx,%eax
mov    %r14,%rdi
mov    %r15d,%esi
mov    %ebx,%edx
mov    %ebp,%ecx
mov    %eax,%r8d
call   1030 <printf@plt>
mov    (%r12),%edi
call   1040 <fflush@plt>
mov    $0xa,%edi
call   1050 <sleep@plt>
jmp    1160 <main+0x20>

LLVM IR (-O0):
@.str = [13 x i8] c"%i %i %i %i\0A\00"
@stdout = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
store i32 0, i32* %9
store i32 20, i32* %10
br label %11
11: ; preds = %11, %2
%12 = call i32 (...) @rand()
%13 = load i32, i32* %10
%14 = srem i32 %12, %13
store i32 %14, i32* %6
%15 = call i32 (...) @rand()
%16 = load i32, i32* %10
%17 = srem i32 %15, %16
store i32 %17, i32* %7
%18 = call i32 (...) @rand()
%19 = srem i32 %18, 2
store i32 %19, i32* %8
%20 = call i32 (...) @rand()
%21 = srem i32 %20, 2
store i32 %21, i32* %9
%22 = load i32, i32* %6
%23 = load i32, i32* %7
%24 = load i32, i32* %8
%25 = load i32, i32* %9
%26 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %22, i32 %23, i32 %24, i32 %25)
%27 = load i32, i32* @stdout
%28 = call i32 @fflush(i32 %27)
%29 = call i32 @sleep(i32 10)
br label %11
}

LLVM IR (-O2):
@.str = [13 x i8] c"%i %i %i %i\0A\00"
@stdout = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
br label %3
3: ; preds = %3, %2
%4 = tail call i32 (...) @rand()
%5 = srem i32 %4, 20
%6 = tail call i32 (...) @rand()
%7 = srem i32 %6, 20
%8 = tail call i32 (...) @rand()
%9 = srem i32 %8, 2
%10 = tail call i32 (...) @rand()
%11 = srem i32 %10, 2
%12 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %5, i32 %7, i32 %9, i32 %11)
%13 = load i32, i32* @stdout
%14 = tail call i32 @fflush(i32 %13)
%15 = tail call i32 @sleep(i32 10)
br label %3
}