#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 uint32_t;
struct mtwist_state {
  int dummy;
};

/* Variables and functions */
struct mtwist_state *mtwist_init(int);
int mtwist_next(struct mtwist_state *);
int /*<<< orphan*/ printf(char *, int, int);
int main(int argc, char *argv[]) {
  int i;
  struct mtwist_state *mt;
  mt = mtwist_init(99973);
  for (i = 0; i < 1000; i++) {
    uint32_t x;
    x = mtwist_next(mt);
    printf("%u, %d\n", x, x % 100);
  }
  return 0;
}


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)
mov    $0x18685,%edi
call   1040 <mtwist_init@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x3e8,-0x14(%rbp)
jge    119c <main+0x6c>
mov    -0x20(%rbp),%rdi
call   1050 <mtwist_next@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%esi
mov    -0x24(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
lea    0xe77(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    115b <main+0x2b>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    $0x18685,%edi
call   1040 <mtwist_init@plt>
mov    %rax,%rbx
mov    $0x3e8,%ebp
lea    0xeb3(%rip),%r14
nopl   (%rax)
mov    %rbx,%rdi
call   1050 <mtwist_next@plt>
movslq %eax,%rsi
imul   $0x51eb851f,%rsi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
imul   $0x64,%eax,%eax
mov    %esi,%edx
sub    %eax,%edx
mov    %r14,%rdi
call   1030 <printf@plt>
add    $0xffffffff,%ebp
jne    1150 <main+0x20>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.mtwist_state = type { i32 }
@.str = [8 x i8] c"%u, %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca %struct.mtwist_state*
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call %struct.mtwist_state* @mtwist_init(i32 99973)
store %struct.mtwist_state* %9, %struct.mtwist_state** %7
store i32 0, i32* %6
br label %10
10: ; preds = %20, %2
%11 = load i32, i32* %6
%12 = icmp slt i32 %11, 1000
br i1 %12, label %13, label %23
13: ; preds = %10
%14 = load %struct.mtwist_state*, %struct.mtwist_state** %7
%15 = call i32 @mtwist_next(%struct.mtwist_state* %14)
store i32 %15, i32* %8
%16 = load i32, i32* %8
%17 = load i32, i32* %8
%18 = srem i32 %17, 100
%19 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %16, i32 %18)
br label %20
20: ; preds = %13
%21 = load i32, i32* %6
%22 = add nsw i32 %21, 1
store i32 %22, i32* %6
br label %10
23: ; preds = %10
ret i32 0
}

LLVM IR (-O2):
%struct.mtwist_state = type { i32 }
@.str = [8 x i8] c"%u, %d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call %struct.mtwist_state* @mtwist_init(i32 99973)
br label %4
4: ; preds = %2, %4
%5 = phi i32 [ 0, %2 ], [ %9, %4 ]
%6 = tail call i32 @mtwist_next(%struct.mtwist_state* %3)
%7 = srem i32 %6, 100
%8 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %6, i32 %7)
%9 = add nuw nsw i32 %5, 1
%10 = icmp eq i32 %9, 1000
br i1 %10, label %11, label %4
11: ; preds = %4
ret i32 0
}