#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 EXIT_FAILURE;
int EXIT_SUCCESS;
unsigned int atoi(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ fputc(unsigned int, int /*<<< orphan*/);
unsigned int rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  if (argc != 3) {
    fprintf(stderr, "Usage: %s size num_chars\n", argv[0]);
    return EXIT_FAILURE;
  }
  unsigned int size = atoi(argv[1]);
  unsigned int num_chars = atoi(argv[2]);
  srand(time(NULL));
  for (unsigned int i = 0; i < size; ++i) {
    fputc(rand() % num_chars, stdout);
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     11ad <main+0x4d>
mov    0x2e59(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe69(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2e35(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1226 <main+0xc6>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x18(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jae    121a <main+0xba>
mov    $0x0,%al
call   1080 <rand@plt>
xor    %edx,%edx
divl   -0x18(%rbp)
mov    %edx,%edi
mov    0x2dcb(%rip),%rax
mov    (%rax),%esi
call   1030 <fputc@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11e4 <main+0x84>
mov    0x2da7(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbp
cmp    $0x3,%edi
jne    11cc <main+0x6c>
mov    0x8(%rbp),%rdi
call   1070 <atoi@plt>
mov    %eax,%ebx
mov    0x10(%rbp),%rdi
call   1070 <atoi@plt>
mov    %eax,%ebp
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
mov    0x2e2e(%rip),%r14
test   %ebx,%ebx
je     11ec <main+0x8c>
mov    0x2e2b(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
call   1080 <rand@plt>
xor    %edx,%edx
div    %ebp
mov    %edx,%edi
mov    (%r15),%esi
call   1030 <fputc@plt>
add    $0xffffffff,%ebx
jne    11b0 <main+0x50>
jmp    11ec <main+0x8c>
mov    0x2e0d(%rip),%rax
mov    (%rax),%edi
mov    0x0(%rbp),%rdx
lea    0xe20(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2dec(%rip),%r14
mov    (%r14),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [26 x i8] c"Usage: %s size num_chars\0A\00"
@EXIT_FAILURE = global i32 0
@stdout = global i32 0
@EXIT_SUCCESS = 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
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 3
br i1 %10, label %11, label %18
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = load i8*, i8** %14
%16 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %15)
%17 = load i32, i32* @EXIT_FAILURE
store i32 %17, i32* %3
br label %44
18: ; preds = %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i32 @atoi(i8* %21)
store i32 %22, i32* %6
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 2
%25 = load i8*, i8** %24
%26 = call i32 @atoi(i8* %25)
store i32 %26, i32* %7
%27 = call i32 @time(i32* null)
%28 = call i32 @srand(i32 %27)
store i32 0, i32* %8
br label %29
29: ; preds = %39, %18
%30 = load i32, i32* %8
%31 = load i32, i32* %6
%32 = icmp ult i32 %30, %31
br i1 %32, label %33, label %42
33: ; preds = %29
%34 = call i32 (...) @rand()
%35 = load i32, i32* %7
%36 = urem i32 %34, %35
%37 = load i32, i32* @stdout
%38 = call i32 @fputc(i32 %36, i32 %37)
br label %39
39: ; preds = %33
%40 = load i32, i32* %8
%41 = add i32 %40, 1
store i32 %41, i32* %8
br label %29
42: ; preds = %29
%43 = load i32, i32* @EXIT_SUCCESS
store i32 %43, i32* %3
br label %44
44: ; preds = %42, %11
%45 = load i32, i32* %3
ret i32 %45
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [26 x i8] c"Usage: %s size num_chars\0A\00"
@EXIT_FAILURE = global i32 0
@stdout = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 3
br i1 %3, label %8, label %4
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = load i8*, i8** %1
%7 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %6)
br label %26
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32 @atoi(i8* %10)
%12 = getelementptr inbounds i8*, i8** %1, i64 2
%13 = load i8*, i8** %12
%14 = tail call i32 @atoi(i8* %13)
%15 = tail call i32 @time(i32* null)
%16 = tail call i32 @srand(i32 %15)
%17 = icmp eq i32 %11, 0
br i1 %17, label %26, label %18
18: ; preds = %8, %18
%19 = phi i32 [ %24, %18 ], [ 0, %8 ]
%20 = tail call i32 (...) @rand()
%21 = urem i32 %20, %14
%22 = load i32, i32* @stdout
%23 = tail call i32 @fputc(i32 %21, i32 %22)
%24 = add nuw i32 %19, 1
%25 = icmp eq i32 %24, %11
br i1 %25, label %26, label %18
26: ; preds = %18, %8, %4
%27 = phi i32* [ @EXIT_FAILURE, %4 ], [ @EXIT_SUCCESS, %8 ], [ @EXIT_SUCCESS, %18 ]
%28 = load i32, i32* %27
ret i32 %28
}