#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 nd_int();
int libcall2(int uno, int dos) {
  if (uno == 0) {
    return 1 + nd_int();
  }
  if (uno == 1) {
    return 2 + nd_int();
  }
  if (uno == 2) {
    return 3 + nd_int();
  }
  return nd_int();
}


x86 assembly (clang, -O0):
<libcall2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    113a <libcall2+0x2a>
mov    $0x0,%al
call   1030 <nd_int@plt>
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    117c <libcall2+0x6c>
cmpl   $0x1,-0x8(%rbp)
jne    1156 <libcall2+0x46>
mov    $0x0,%al
call   1030 <nd_int@plt>
add    $0x2,%eax
mov    %eax,-0x4(%rbp)
jmp    117c <libcall2+0x6c>
cmpl   $0x2,-0x8(%rbp)
jne    1172 <libcall2+0x62>
mov    $0x0,%al
call   1030 <nd_int@plt>
add    $0x3,%eax
mov    %eax,-0x4(%rbp)
jmp    117c <libcall2+0x6c>
mov    $0x0,%al
call   1030 <nd_int@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<libcall2>:
push   %rax
xor    %eax,%eax
cmp    $0x2,%edi
je     112b <libcall2+0x1b>
cmp    $0x1,%edi
je     1135 <libcall2+0x25>
test   %edi,%edi
jne    113f <libcall2+0x2f>
call   1030 <nd_int@plt>
add    $0x1,%eax
pop    %rcx
ret
call   1030 <nd_int@plt>
add    $0x3,%eax
pop    %rcx
ret
call   1030 <nd_int@plt>
add    $0x2,%eax
pop    %rcx
ret
pop    %rcx
jmp    1030 <nd_int@plt>

LLVM IR (-O0):
define i32 @libcall2(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%6 = load i32, i32* %4
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = call i32 (...) @nd_int()
%10 = add nsw i32 1, %9
store i32 %10, i32* %3
br label %25
11: ; preds = %2
%12 = load i32, i32* %4
%13 = icmp eq i32 %12, 1
br i1 %13, label %14, label %17
14: ; preds = %11
%15 = call i32 (...) @nd_int()
%16 = add nsw i32 2, %15
store i32 %16, i32* %3
br label %25
17: ; preds = %11
%18 = load i32, i32* %4
%19 = icmp eq i32 %18, 2
br i1 %19, label %20, label %23
20: ; preds = %17
%21 = call i32 (...) @nd_int()
%22 = add nsw i32 3, %21
store i32 %22, i32* %3
br label %25
23: ; preds = %17
%24 = call i32 (...) @nd_int()
store i32 %24, i32* %3
br label %25
25: ; preds = %23, %20, %14, %8
%26 = load i32, i32* %3
ret i32 %26
}

LLVM IR (-O2):
define i32 @libcall2(i32 %0, i32 %1) {
switch i32 %0, label %12 [
i32 0, label %3
i32 1, label %6
i32 2, label %9
]
3: ; preds = %2
%4 = tail call i32 (...) @nd_int()
%5 = add nsw i32 %4, 1
br label %14
6: ; preds = %2
%7 = tail call i32 (...) @nd_int()
%8 = add nsw i32 %7, 2
br label %14
9: ; preds = %2
%10 = tail call i32 (...) @nd_int()
%11 = add nsw i32 %10, 3
br label %14
12: ; preds = %2
%13 = tail call i32 (...) @nd_int()
br label %14
14: ; preds = %12, %9, %6, %3
%15 = phi i32 [ %5, %3 ], [ %8, %6 ], [ %11, %9 ], [ %13, %12 ]
ret i32 %15
}