#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 int32_t;

/* Variables and functions */
int nd();
int32_t compute1(int32_t *t) {
  int i1 = nd();
  int y;
  switch (nd()) {
  case 1:
    y = 2;
    break;
  case 2:
    y = 4;
    break;
  case 3:
    y = 6;
    break;
  default:
    y = 15;
    break;
  }
  t[y] = 100;
  return t[2] + t[4] + t[6] + t[15];
}


x86 assembly (clang, -O0):
<compute1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
xor    %eax,%eax
mov    %al,-0x15(%rbp)
call   1030 <nd@plt>
mov    %eax,%ecx
mov    -0x15(%rbp),%al
mov    %ecx,-0xc(%rbp)
call   1030 <nd@plt>
mov    %eax,%ecx
mov    %ecx,-0x14(%rbp)
sub    $0x1,%eax
je     1168 <compute1+0x58>
jmp    1146 <compute1+0x36>
mov    -0x14(%rbp),%eax
sub    $0x2,%eax
je     1174 <compute1+0x64>
jmp    1157 <compute1+0x47>
mov    -0x14(%rbp),%eax
sub    $0x3,%eax
je     1180 <compute1+0x70>
jmp    118c <compute1+0x7c>
movl   $0x2,-0x10(%rbp)
jmp    1193 <compute1+0x83>
movl   $0x4,-0x10(%rbp)
jmp    1193 <compute1+0x83>
movl   $0x6,-0x10(%rbp)
jmp    1193 <compute1+0x83>
movl   $0xf,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movl   $0x64,(%rax,%rcx,4)
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%eax
mov    -0x8(%rbp),%rcx
add    0x10(%rcx),%eax
mov    -0x8(%rbp),%rcx
add    0x18(%rcx),%eax
mov    -0x8(%rbp),%rcx
add    0x3c(%rcx),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compute1>:
push   %rbx
mov    %rdi,%rbx
xor    %eax,%eax
call   1030 <nd@plt>
xor    %eax,%eax
call   1030 <nd@plt>
add    $0xffffffff,%eax
cmp    $0x3,%eax
lea    0x2(%rax,%rax,1),%rax
mov    $0xf,%ecx
cmovb  %rax,%rcx
movl   $0x64,(%rbx,%rcx,4)
mov    0x10(%rbx),%eax
add    0x8(%rbx),%eax
add    0x18(%rbx),%eax
add    0x3c(%rbx),%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @compute1(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
store i32* %0, i32** %2
%5 = call i32 (...) @nd()
store i32 %5, i32* %3
%6 = call i32 (...) @nd()
switch i32 %6, label %10 [
i32 1, label %7
i32 2, label %8
i32 3, label %9
]
7: ; preds = %1
store i32 2, i32* %4
br label %11
8: ; preds = %1
store i32 4, i32* %4
br label %11
9: ; preds = %1
store i32 6, i32* %4
br label %11
10: ; preds = %1
store i32 15, i32* %4
br label %11
11: ; preds = %10, %9, %8, %7
%12 = load i32*, i32** %2
%13 = load i32, i32* %4
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i32, i32* %12, i64 %14
store i32 100, i32* %15
%16 = load i32*, i32** %2
%17 = getelementptr inbounds i32, i32* %16, i64 2
%18 = load i32, i32* %17
%19 = load i32*, i32** %2
%20 = getelementptr inbounds i32, i32* %19, i64 4
%21 = load i32, i32* %20
%22 = add nsw i32 %18, %21
%23 = load i32*, i32** %2
%24 = getelementptr inbounds i32, i32* %23, i64 6
%25 = load i32, i32* %24
%26 = add nsw i32 %22, %25
%27 = load i32*, i32** %2
%28 = getelementptr inbounds i32, i32* %27, i64 15
%29 = load i32, i32* %28
%30 = add nsw i32 %26, %29
ret i32 %30
}

LLVM IR (-O2):
define i32 @compute1(i32* nocapture %0) {
%2 = tail call i32 (...) @nd()
%3 = tail call i32 (...) @nd()
%4 = add i32 %3, -1
%5 = icmp ult i32 %4, 3
%6 = zext i32 %4 to i64
%7 = shl nuw nsw i64 %6, 1
%8 = add nuw nsw i64 %7, 2
%9 = select i1 %5, i64 %8, i64 15
%10 = getelementptr inbounds i32, i32* %0, i64 %9
store i32 100, i32* %10
%11 = getelementptr inbounds i32, i32* %0, i64 2
%12 = load i32, i32* %11
%13 = getelementptr inbounds i32, i32* %0, i64 4
%14 = load i32, i32* %13
%15 = add nsw i32 %14, %12
%16 = getelementptr inbounds i32, i32* %0, i64 6
%17 = load i32, i32* %16
%18 = add nsw i32 %15, %17
%19 = getelementptr inbounds i32, i32* %0, i64 15
%20 = load i32, i32* %19
%21 = add nsw i32 %18, %20
ret i32 %21
}