#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*/ Load(char *, int);
int rand();
int main() {
  int i;
  for (i = 0; i < 100; i++) {
    switch (1 + rand() % 2) {
    case 1:
      Load("libone.so", 1);
      break;
    case 2:
      Load("libtwo.so", 2);
      break;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x64,-0x8(%rbp)
jge    11bb <main+0x9b>
xor    %eax,%eax
call   1040 <rand@plt>
mov    %eax,%ecx
mov    %ecx,%eax
shr    $0x1f,%eax
mov    %ecx,%edx
add    %eax,%edx
and    $0xfffffffe,%edx
mov    %ecx,%eax
neg    %edx
mov    %edx,%ecx
lea    0x1(%rax,%rcx,1),%eax
mov    %eax,-0xc(%rbp)
sub    $0x1,%eax
je     1181 <main+0x61>
jmp    1170 <main+0x50>
mov    -0xc(%rbp),%eax
sub    $0x2,%eax
je     1197 <main+0x77>
jmp    11a8 <main+0x88>
lea    0xe78(%rip),%rdi
mov    $0x1,%esi
call   1030 <Load@plt>
jmp    11a8 <main+0x88>
lea    0xe6c(%rip),%rdi
mov    $0x2,%esi
call   1030 <Load@plt>
jmp    11ad <main+0x8d>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1136 <main+0x16>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    $0x64,%ebp
lea    0xeda(%rip),%r14
lea    0xec9(%rip),%rbx
jmp    1152 <main+0x32>
nopl   0x0(%rax)
mov    %r14,%rdi
mov    $0x2,%esi
call   1030 <Load@plt>
add    $0xffffffff,%ebp
je     1178 <main+0x58>
xor    %eax,%eax
call   1040 <rand@plt>
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
and    $0xfffffffe,%ecx
sub    %ecx,%eax
cmp    $0x1,%eax
je     1140 <main+0x20>
test   %eax,%eax
jne    114d <main+0x2d>
mov    %rbx,%rdi
mov    $0x1,%esi
jmp    1148 <main+0x28>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"libone.so\00"
@.str.1 = [10 x i8] c"libtwo.so\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
br label %3
3: ; preds = %15, %0
%4 = load i32, i32* %2
%5 = icmp slt i32 %4, 100
br i1 %5, label %6, label %18
6: ; preds = %3
%7 = call i32 (...) @rand()
%8 = srem i32 %7, 2
%9 = add nsw i32 1, %8
switch i32 %9, label %14 [
i32 1, label %10
i32 2, label %12
]
10: ; preds = %6
%11 = call i32 @Load(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 1)
br label %14
12: ; preds = %6
%13 = call i32 @Load(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 2)
br label %14
14: ; preds = %6, %12, %10
br label %15
15: ; preds = %14
%16 = load i32, i32* %2
%17 = add nsw i32 %16, 1
store i32 %17, i32* %2
br label %3
18: ; preds = %3
ret i32 0
}

LLVM IR (-O2):
@.str = [10 x i8] c"libone.so\00"
@.str.1 = [10 x i8] c"libtwo.so\00"
define i32 @main() {
br label %1
1: ; preds = %0, %9
%2 = phi i32 [ 0, %0 ], [ %10, %9 ]
%3 = tail call i32 (...) @rand()
%4 = srem i32 %3, 2
switch i32 %4, label %9 [
i32 0, label %5
i32 1, label %7
]
5: ; preds = %1
%6 = tail call i32 @Load(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 1)
br label %9
7: ; preds = %1
%8 = tail call i32 @Load(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 2)
br label %9
9: ; preds = %5, %7, %1
%10 = add nuw nsw i32 %2, 1
%11 = icmp eq i32 %10, 100
br i1 %11, label %12, label %1
12: ; preds = %9
ret i32 0
}