#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__ bar(int);
scalar_t__ bar2(int);
int /*<<< orphan*/ baz(int);
void foo(int y) {
  int a = 0;
  if (y == 6) {
    a += bar(7);
    a += bar2(6);
  } else {
    a += bar2(6);
    a += bar(7);
  }
  baz(a);
}


x86 assembly (clang, -O0):
<foo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x6,-0x4(%rbp)
jne    117f <foo+0x4f>
mov    $0x7,%edi
call   1050 <bar@plt>
mov    %rax,%rcx
movslq -0x8(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x8(%rbp)
mov    $0x6,%edi
call   1030 <bar2@plt>
mov    %rax,%rcx
movslq -0x8(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x8(%rbp)
jmp    11ad <foo+0x7d>
mov    $0x6,%edi
call   1030 <bar2@plt>
mov    %rax,%rcx
movslq -0x8(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x8(%rbp)
mov    $0x7,%edi
call   1050 <bar@plt>
mov    %rax,%rcx
movslq -0x8(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1040 <baz@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<foo>:
push   %rbx
cmp    $0x6,%edi
jne    1159 <foo+0x29>
mov    $0x7,%edi
call   1050 <bar@plt>
mov    %rax,%rbx
mov    $0x6,%edi
call   1030 <bar2@plt>
movslq %ebx,%rdi
add    %rax,%rdi
pop    %rbx
jmp    1040 <baz@plt>
mov    $0x6,%edi
call   1030 <bar2@plt>
mov    %rax,%rbx
mov    $0x7,%edi
call   1050 <bar@plt>
mov    %rax,%rdi
add    %rbx,%rdi
pop    %rbx
jmp    1040 <baz@plt>

LLVM IR (-O0):
define void @foo(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %3
%4 = load i32, i32* %2
%5 = icmp eq i32 %4, 6
br i1 %5, label %6, label %17
6: ; preds = %1
%7 = call i64 @bar(i32 7)
%8 = load i32, i32* %3
%9 = sext i32 %8 to i64
%10 = add nsw i64 %9, %7
%11 = trunc i64 %10 to i32
store i32 %11, i32* %3
%12 = call i64 @bar2(i32 6)
%13 = load i32, i32* %3
%14 = sext i32 %13 to i64
%15 = add nsw i64 %14, %12
%16 = trunc i64 %15 to i32
store i32 %16, i32* %3
br label %28
17: ; preds = %1
%18 = call i64 @bar2(i32 6)
%19 = load i32, i32* %3
%20 = sext i32 %19 to i64
%21 = add nsw i64 %20, %18
%22 = trunc i64 %21 to i32
store i32 %22, i32* %3
%23 = call i64 @bar(i32 7)
%24 = load i32, i32* %3
%25 = sext i32 %24 to i64
%26 = add nsw i64 %25, %23
%27 = trunc i64 %26 to i32
store i32 %27, i32* %3
br label %28
28: ; preds = %17, %6
%29 = load i32, i32* %3
%30 = call i32 @baz(i32 %29)
ret void
}

LLVM IR (-O2):
define void @foo(i32 %0) {
%2 = icmp eq i32 %0, 6
br i1 %2, label %3, label %9
3: ; preds = %1
%4 = tail call i64 @bar(i32 7)
%5 = tail call i64 @bar2(i32 6)
%6 = shl i64 %4, 32
%7 = ashr exact i64 %6, 32
%8 = add nsw i64 %7, %5
br label %13
9: ; preds = %1
%10 = tail call i64 @bar2(i32 6)
%11 = tail call i64 @bar(i32 7)
%12 = add i64 %11, %10
br label %13
13: ; preds = %9, %3
%14 = phi i64 [ %8, %3 ], [ %12, %9 ]
%15 = trunc i64 %14 to i32
%16 = tail call i32 @baz(i32 %15)
ret void
}