#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 */
scalar_t__ __getanum(int, int);
__attribute__((no)) const char *somejunk(char opt) {
  char *msg = "teststring";
  for (int i = 0; i < 5; i++) {
    if (opt == 'a') {
      opt += __getanum(i, 4);
    } else if (opt == 'b') {
      opt += __getanum(i, 5);
    } else {
      opt += __getanum(i, 6);
    }
  }
  msg[0] = opt;
  return msg;
}


x86 assembly (clang, -O0):
<somejunk>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
lea    0xedb(%rip),%rax
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x5,-0x14(%rbp)
jge    11c7 <somejunk+0xb7>
movsbl -0x1(%rbp),%eax
cmp    $0x61,%eax
jne    1167 <somejunk+0x57>
mov    -0x14(%rbp),%edi
mov    $0x4,%esi
call   1030 <__getanum@plt>
mov    %rax,%rcx
movsbq -0x1(%rbp),%rax
add    %rcx,%rax
mov    %al,-0x1(%rbp)
jmp    11b4 <somejunk+0xa4>
movsbl -0x1(%rbp),%eax
cmp    $0x62,%eax
jne    1194 <somejunk+0x84>
mov    -0x14(%rbp),%edi
mov    $0x5,%esi
call   1030 <__getanum@plt>
mov    %rax,%rcx
movsbq -0x1(%rbp),%rax
add    %rcx,%rax
mov    %al,-0x1(%rbp)
jmp    11af <somejunk+0x9f>
mov    -0x14(%rbp),%edi
mov    $0x6,%esi
call   1030 <__getanum@plt>
mov    %rax,%rcx
movsbq -0x1(%rbp),%rax
add    %rcx,%rax
mov    %al,-0x1(%rbp)
jmp    11b4 <somejunk+0xa4>
jmp    11b9 <somejunk+0xa9>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1130 <somejunk+0x20>
mov    -0x1(%rbp),%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<somejunk>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebp
xor    %eax,%eax
cmp    $0x62,%bpl
sete   %al
mov    $0x6,%r14d
mov    $0x6,%esi
sub    %eax,%esi
cmp    $0x61,%bpl
mov    $0x4,%r15d
cmove  %r15d,%esi
xor    %edi,%edi
call   1030 <__getanum@plt>
mov    %rax,%rbx
add    %bpl,%bl
xor    %eax,%eax
cmp    $0x62,%bl
sete   %al
mov    $0x6,%esi
sub    %eax,%esi
cmp    $0x61,%bl
cmove  %r15d,%esi
mov    $0x1,%edi
call   1030 <__getanum@plt>
mov    %rax,%rbp
add    %bl,%bpl
xor    %eax,%eax
cmp    $0x62,%bpl
sete   %al
mov    $0x6,%esi
sub    %eax,%esi
cmp    $0x61,%bpl
cmove  %r15d,%esi
mov    $0x2,%edi
call   1030 <__getanum@plt>
mov    %rax,%rbx
add    %bpl,%bl
xor    %eax,%eax
cmp    $0x62,%bl
sete   %al
mov    $0x6,%esi
sub    %eax,%esi
cmp    $0x61,%bl
cmove  %r15d,%esi
mov    $0x3,%edi
call   1030 <__getanum@plt>
add    %bl,%al
xor    %ecx,%ecx
cmp    $0x62,%al
sete   %cl
sub    %ecx,%r14d
cmp    $0x61,%al
cmove  %r15d,%r14d
mov    $0x4,%edi
mov    %r14d,%esi
call   1030 <__getanum@plt>
lea    0xe22(%rip),%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"teststring\00"
define i8* @somejunk(i8 signext %0) {
%2 = alloca i8
%3 = alloca i8*
%4 = alloca i32
store i8 %0, i8* %2
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8** %3
store i32 0, i32* %4
br label %5
5: ; preds = %39, %1
%6 = load i32, i32* %4
%7 = icmp slt i32 %6, 5
br i1 %7, label %8, label %42
8: ; preds = %5
%9 = load i8, i8* %2
%10 = sext i8 %9 to i32
%11 = icmp eq i32 %10, 97
br i1 %11, label %12, label %19
12: ; preds = %8
%13 = load i32, i32* %4
%14 = call i64 @__getanum(i32 %13, i32 4)
%15 = load i8, i8* %2
%16 = sext i8 %15 to i64
%17 = add nsw i64 %16, %14
%18 = trunc i64 %17 to i8
store i8 %18, i8* %2
br label %38
19: ; preds = %8
%20 = load i8, i8* %2
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %21, 98
br i1 %22, label %23, label %30
23: ; preds = %19
%24 = load i32, i32* %4
%25 = call i64 @__getanum(i32 %24, i32 5)
%26 = load i8, i8* %2
%27 = sext i8 %26 to i64
%28 = add nsw i64 %27, %25
%29 = trunc i64 %28 to i8
store i8 %29, i8* %2
br label %37
30: ; preds = %19
%31 = load i32, i32* %4
%32 = call i64 @__getanum(i32 %31, i32 6)
%33 = load i8, i8* %2
%34 = sext i8 %33 to i64
%35 = add nsw i64 %34, %32
%36 = trunc i64 %35 to i8
store i8 %36, i8* %2
br label %37
37: ; preds = %30, %23
br label %38
38: ; preds = %37, %12
br label %39
39: ; preds = %38
%40 = load i32, i32* %4
%41 = add nsw i32 %40, 1
store i32 %41, i32* %4
br label %5
42: ; preds = %5
%43 = load i8, i8* %2
%44 = load i8*, i8** %3
%45 = getelementptr inbounds i8, i8* %44, i64 0
store i8 %43, i8* %45
%46 = load i8*, i8** %3
ret i8* %46
}

LLVM IR (-O2):
@.str = [11 x i8] c"teststring\00"
define i8* @somejunk(i8 signext %0) {
%2 = icmp eq i8 %0, 98
%3 = select i1 %2, i32 5, i32 6
%4 = icmp eq i8 %0, 97
%5 = select i1 %4, i32 4, i32 %3
%6 = tail call i64 @__getanum(i32 0, i32 %5)
%7 = trunc i64 %6 to i8
%8 = add i8 %7, %0
%9 = icmp eq i8 %8, 98
%10 = select i1 %9, i32 5, i32 6
%11 = icmp eq i8 %8, 97
%12 = select i1 %11, i32 4, i32 %10
%13 = tail call i64 @__getanum(i32 1, i32 %12)
%14 = trunc i64 %13 to i8
%15 = add i8 %8, %14
%16 = icmp eq i8 %15, 98
%17 = select i1 %16, i32 5, i32 6
%18 = icmp eq i8 %15, 97
%19 = select i1 %18, i32 4, i32 %17
%20 = tail call i64 @__getanum(i32 2, i32 %19)
%21 = trunc i64 %20 to i8
%22 = add i8 %15, %21
%23 = icmp eq i8 %22, 98
%24 = select i1 %23, i32 5, i32 6
%25 = icmp eq i8 %22, 97
%26 = select i1 %25, i32 4, i32 %24
%27 = tail call i64 @__getanum(i32 3, i32 %26)
%28 = trunc i64 %27 to i8
%29 = add i8 %22, %28
%30 = icmp eq i8 %29, 98
%31 = select i1 %30, i32 5, i32 6
%32 = icmp eq i8 %29, 97
%33 = select i1 %32, i32 4, i32 %31
%34 = tail call i64 @__getanum(i32 4, i32 %33)
ret i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0)
}