#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 getchar();
int /*<<< orphan*/ lower(char *, int);
int /*<<< orphan*/ printf(char *, char *);
int rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int /*<<< orphan*/ upper(char *, int);
int main(int argc, char **argv) {
  srand(time(NULL));
  char input_string[1000];
  char c;
  int i = 0;
  while ((c = getchar()) != '\0') {
    input_string[i++] = c;
  }
  input_string[i] = '\0';
  for (i = 0; i < 1000; i++) {
    (rand() & 1) ? upper(input_string, i) : lower(input_string, i);
  }
  printf("Output: %s \n", input_string);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
movl   $0x0,-0x408(%rbp)
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %al,-0x401(%rbp)
movsbl %al,%eax
cmp    $0x0,%eax
je     11e1 <main+0x71>
mov    -0x401(%rbp),%cl
mov    -0x408(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x408(%rbp)
cltq
mov    %cl,-0x400(%rbp,%rax,1)
jmp    11a3 <main+0x33>
movslq -0x408(%rbp),%rax
movb   $0x0,-0x400(%rbp,%rax,1)
movl   $0x0,-0x408(%rbp)
cmpl   $0x3e8,-0x408(%rbp)
jge    125a <main+0xea>
mov    $0x0,%al
call   1090 <rand@plt>
and    $0x1,%eax
cmp    $0x0,%eax
je     1234 <main+0xc4>
lea    -0x400(%rbp),%rdi
mov    -0x408(%rbp),%esi
call   1070 <upper@plt>
jmp    1246 <main+0xd6>
lea    -0x400(%rbp),%rdi
mov    -0x408(%rbp),%esi
call   1080 <lower@plt>
mov    -0x408(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x408(%rbp)
jmp    11fa <main+0x8a>
lea    -0x400(%rbp),%rsi
lea    0xd98(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x3e8,%rsp
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
mov    $0x0,%ecx
test   %al,%al
je     11b4 <main+0x44>
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    %al,(%rsp,%rbx,1)
add    $0x1,%rbx
xor    %eax,%eax
call   1050 <getchar@plt>
test   %al,%al
jne    11a0 <main+0x30>
mov    %ebx,%ecx
movb   $0x0,(%rsp,%rcx,1)
mov    %rsp,%rbx
xor    %ebp,%ebp
jmp    11d0 <main+0x60>
nop
call   1080 <lower@plt>
add    $0x1,%ebp
cmp    $0x3e8,%ebp
je     11e7 <main+0x77>
xor    %eax,%eax
call   1090 <rand@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
test   $0x1,%al
je     11c0 <main+0x50>
call   1070 <upper@plt>
jmp    11c5 <main+0x55>
lea    0xe12(%rip),%rdi
mov    %rsp,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x3e8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [13 x i8] c"Output: %s \0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [1000 x i8]
%7 = alloca i8
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i32 @time(i32* null)
%10 = call i32 @srand(i32 %9)
store i32 0, i32* %8
br label %11
11: ; preds = %15, %2
%12 = call signext i8 (...) @getchar()
store i8 %12, i8* %7
%13 = sext i8 %12 to i32
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %21
15: ; preds = %11
%16 = load i8, i8* %7
%17 = load i32, i32* %8
%18 = add nsw i32 %17, 1
store i32 %18, i32* %8
%19 = sext i32 %17 to i64
%20 = getelementptr inbounds [1000 x i8], [1000 x i8]* %6, i64 0, i64 %19
store i8 %16, i8* %20
br label %11
21: ; preds = %11
%22 = load i32, i32* %8
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [1000 x i8], [1000 x i8]* %6, i64 0, i64 %23
store i8 0, i8* %24
store i32 0, i32* %8
br label %25
25: ; preds = %42, %21
%26 = load i32, i32* %8
%27 = icmp slt i32 %26, 1000
br i1 %27, label %28, label %45
28: ; preds = %25
%29 = call i32 (...) @rand()
%30 = and i32 %29, 1
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %36
32: ; preds = %28
%33 = getelementptr inbounds [1000 x i8], [1000 x i8]* %6, i64 0, i64 0
%34 = load i32, i32* %8
%35 = call i32 @upper(i8* %33, i32 %34)
br label %40
36: ; preds = %28
%37 = getelementptr inbounds [1000 x i8], [1000 x i8]* %6, i64 0, i64 0
%38 = load i32, i32* %8
%39 = call i32 @lower(i8* %37, i32 %38)
br label %40
40: ; preds = %36, %32
%41 = phi i32 [ %35, %32 ], [ %39, %36 ]
br label %42
42: ; preds = %40
%43 = load i32, i32* %8
%44 = add nsw i32 %43, 1
store i32 %44, i32* %8
br label %25
45: ; preds = %25
%46 = getelementptr inbounds [1000 x i8], [1000 x i8]* %6, i64 0, i64 0
%47 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %46)
%48 = load i32, i32* %3
ret i32 %48
}

LLVM IR (-O2):
@.str = [13 x i8] c"Output: %s \0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [1000 x i8]
%4 = tail call i32 @time(i32* null)
%5 = tail call i32 @srand(i32 %4)
%6 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%7 = tail call signext i8 (...) @getchar()
%8 = icmp eq i8 %7, 0
br i1 %8, label %18, label %9
9: ; preds = %2, %9
%10 = phi i64 [ %12, %9 ], [ 0, %2 ]
%11 = phi i8 [ %14, %9 ], [ %7, %2 ]
%12 = add nuw i64 %10, 1
%13 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 %10
store i8 %11, i8* %13
%14 = tail call signext i8 (...) @getchar()
%15 = icmp eq i8 %14, 0
br i1 %15, label %16, label %9
16: ; preds = %9
%17 = and i64 %12, 4294967295
br label %18
18: ; preds = %16, %2
%19 = phi i64 [ 0, %2 ], [ %17, %16 ]
%20 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 %19
store i8 0, i8* %20
br label %21
21: ; preds = %18, %30
%22 = phi i32 [ 0, %18 ], [ %31, %30 ]
%23 = call i32 (...) @rand()
%24 = and i32 %23, 1
%25 = icmp eq i32 %24, 0
br i1 %25, label %28, label %26
26: ; preds = %21
%27 = call i32 @upper(i8* %6, i32 %22)
br label %30
28: ; preds = %21
%29 = call i32 @lower(i8* %6, i32 %22)
br label %30
30: ; preds = %26, %28
%31 = add nuw nsw i32 %22, 1
%32 = icmp eq i32 %31, 1000
br i1 %32, label %33, label %21
33: ; preds = %30
%34 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %6)
ret i32 0
}