#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int, int, int, int);
int rand();
void generate_records(int i, FILE *strm) {
  int t = 0;
  int x = rand() % 100;
  int y = rand() % 100;
  for (t = 0; t <= 200; ++t) {
    fprintf(strm, "%d %d %d %d\n", i, t, x, y);
    int vx = rand() % 11 - 5;
    int vy = rand() % 11 - 5;
    x += vx;
    y += vy;
  }
}


x86 assembly (clang, -O0):
<generate_records>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    $0x0,%al
call   1040 <rand@plt>
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %edx,-0x18(%rbp)
mov    $0x0,%al
call   1040 <rand@plt>
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %edx,-0x1c(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0xc8,-0x14(%rbp)
jg     11d6 <generate_records+0xb6>
mov    -0x10(%rbp),%rdi
mov    -0x4(%rbp),%edx
mov    -0x14(%rbp),%ecx
mov    -0x18(%rbp),%r8d
mov    -0x1c(%rbp),%r9d
lea    0xe79(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x0,%al
call   1040 <rand@plt>
mov    $0xb,%ecx
cltd
idiv   %ecx
sub    $0x5,%edx
mov    %edx,-0x20(%rbp)
mov    $0x0,%al
call   1040 <rand@plt>
mov    $0xb,%ecx
cltd
idiv   %ecx
sub    $0x5,%edx
mov    %edx,-0x24(%rbp)
mov    -0x20(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x24(%rbp),%eax
add    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1161 <generate_records+0x41>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<generate_records>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %edi,%r15d
xor    %eax,%eax
call   1040 <rand@plt>
movslq %eax,%r13
imul   $0x51eb851f,%r13,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
imul   $0x64,%eax,%eax
sub    %eax,%r13d
xor    %eax,%eax
call   1040 <rand@plt>
movslq %eax,%rbp
imul   $0x51eb851f,%rbp,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
imul   $0x64,%eax,%eax
sub    %eax,%ebp
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
lea    0xe76(%rip),%rsi
mov    %r15d,%edx
mov    %ebx,%ecx
mov    %r13d,%r8d
mov    %ebp,%r9d
call   1030 <fprintf@plt>
xor    %eax,%eax
call   1040 <rand@plt>
movslq %eax,%r12
imul   $0x2e8ba2e9,%r12,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x21,%rax
add    %ecx,%eax
lea    (%rax,%rax,4),%ecx
lea    (%rax,%rcx,2),%eax
sub    %eax,%r12d
xor    %eax,%eax
call   1040 <rand@plt>
cltq
imul   $0x2e8ba2e9,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x21,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,4),%edx
lea    (%rcx,%rdx,2),%ecx
sub    %ecx,%eax
add    %r12d,%r13d
add    $0xfffffffb,%r13d
add    %eax,%ebp
add    $0xfffffffb,%ebp
add    $0x1,%ebx
cmp    $0xc9,%ebx
jne    1180 <generate_records+0x60>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [13 x i8] c"%d %d %d %d\0A\00"
define void @generate_records(i32 %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %3
store i32* %1, i32** %4
store i32 0, i32* %5
%10 = call i32 (...) @rand()
%11 = srem i32 %10, 100
store i32 %11, i32* %6
%12 = call i32 (...) @rand()
%13 = srem i32 %12, 100
store i32 %13, i32* %7
store i32 0, i32* %5
br label %14
14: ; preds = %36, %2
%15 = load i32, i32* %5
%16 = icmp sle i32 %15, 200
br i1 %16, label %17, label %39
17: ; preds = %14
%18 = load i32*, i32** %4
%19 = load i32, i32* %3
%20 = load i32, i32* %5
%21 = load i32, i32* %6
%22 = load i32, i32* %7
%23 = call i32 @fprintf(i32* %18, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %19, i32 %20, i32 %21, i32 %22)
%24 = call i32 (...) @rand()
%25 = srem i32 %24, 11
%26 = sub nsw i32 %25, 5
store i32 %26, i32* %8
%27 = call i32 (...) @rand()
%28 = srem i32 %27, 11
%29 = sub nsw i32 %28, 5
store i32 %29, i32* %9
%30 = load i32, i32* %8
%31 = load i32, i32* %6
%32 = add nsw i32 %31, %30
store i32 %32, i32* %6
%33 = load i32, i32* %9
%34 = load i32, i32* %7
%35 = add nsw i32 %34, %33
store i32 %35, i32* %7
br label %36
36: ; preds = %17
%37 = load i32, i32* %5
%38 = add nsw i32 %37, 1
store i32 %38, i32* %5
br label %14
39: ; preds = %14
ret void
}

LLVM IR (-O2):
@.str = [13 x i8] c"%d %d %d %d\0A\00"
define void @generate_records(i32 %0, i32* nocapture %1) {
%3 = tail call i32 (...) @rand()
%4 = srem i32 %3, 100
%5 = tail call i32 (...) @rand()
%6 = srem i32 %5, 100
br label %7
7: ; preds = %2, %7
%8 = phi i32 [ 0, %2 ], [ %20, %7 ]
%9 = phi i32 [ %4, %2 ], [ %17, %7 ]
%10 = phi i32 [ %6, %2 ], [ %19, %7 ]
%11 = tail call i32 @fprintf(i32* %1, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %0, i32 %8, i32 %9, i32 %10)
%12 = tail call i32 (...) @rand()
%13 = srem i32 %12, 11
%14 = tail call i32 (...) @rand()
%15 = srem i32 %14, 11
%16 = add i32 %9, -5
%17 = add i32 %16, %13
%18 = add i32 %10, -5
%19 = add i32 %18, %15
%20 = add nuw nsw i32 %8, 1
%21 = icmp eq i32 %20, 201
br i1 %21, label %22, label %7
22: ; preds = %7
ret void
}