#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*/ printf(char *, unsigned int, unsigned int, unsigned int,
                          unsigned int, ...);
int /*<<< orphan*/ set_bit(unsigned int *, unsigned int, unsigned int);
void test_set_bit(unsigned x, unsigned n, unsigned v, unsigned expected) {
  unsigned o = x;
  set_bit(&x, n, v);
  if (x != expected) {
    printf("set_bit(0x%08x,%u,%u): 0x%08x, expected 0x%08x\n", o, n, v, x,
           expected);
  } else {
    printf("set_bit(0x%08x,%u,%u): 0x%08x, correct\n", o, n, v, x);
  }
}


x86 assembly (clang, -O0):
<test_set_bit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    -0x4(%rbp),%rdi
call   1040 <set_bit@plt>
mov    -0x4(%rbp),%eax
cmp    -0x10(%rbp),%eax
je     1179 <test_set_bit+0x59>
mov    -0x14(%rbp),%esi
mov    -0x8(%rbp),%edx
mov    -0xc(%rbp),%ecx
mov    -0x4(%rbp),%r8d
mov    -0x10(%rbp),%r9d
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1194 <test_set_bit+0x74>
mov    -0x14(%rbp),%esi
mov    -0x8(%rbp),%edx
mov    -0xc(%rbp),%ecx
mov    -0x4(%rbp),%r8d
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_set_bit>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %ecx,%r14d
mov    %edx,%r15d
mov    %esi,%ebx
mov    %edi,%ebp
mov    %edi,0x4(%rsp)
lea    0x4(%rsp),%rdi
call   1040 <set_bit@plt>
mov    0x4(%rsp),%r8d
cmp    %r14d,%r8d
jne    1163 <test_set_bit+0x43>
lea    0xee0(%rip),%rdi
mov    %ebp,%esi
mov    %ebx,%edx
mov    %r15d,%ecx
mov    %r14d,%r8d
xor    %eax,%eax
call   1030 <printf@plt>
jmp    117b <test_set_bit+0x5b>
lea    0xe96(%rip),%rdi
mov    %ebp,%esi
mov    %ebx,%edx
mov    %r15d,%ecx
mov    %r14d,%r9d
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [48 x i8] c"set_bit(0x%08x,%u,%u): 0x%08x, expected 0x%08x\0A\00"
@.str.1 = [40 x i8] c"set_bit(0x%08x,%u,%u): 0x%08x, correct\0A\00"
define void @test_set_bit(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%10 = load i32, i32* %5
store i32 %10, i32* %9
%11 = load i32, i32* %6
%12 = load i32, i32* %7
%13 = call i32 @set_bit(i32* %5, i32 %11, i32 %12)
%14 = load i32, i32* %5
%15 = load i32, i32* %8
%16 = icmp ne i32 %14, %15
br i1 %16, label %17, label %24
17: ; preds = %4
%18 = load i32, i32* %9
%19 = load i32, i32* %6
%20 = load i32, i32* %7
%21 = load i32, i32* %5
%22 = load i32, i32* %8
%23 = call i32 (i8*, i32, i32, i32, i32, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0), i32 %18, i32 %19, i32 %20, i32 %21, i32 %22)
br label %30
24: ; preds = %4
%25 = load i32, i32* %9
%26 = load i32, i32* %6
%27 = load i32, i32* %7
%28 = load i32, i32* %5
%29 = call i32 (i8*, i32, i32, i32, i32, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0), i32 %25, i32 %26, i32 %27, i32 %28)
br label %30
30: ; preds = %24, %17
ret void
}

LLVM IR (-O2):
@.str = [48 x i8] c"set_bit(0x%08x,%u,%u): 0x%08x, expected 0x%08x\0A\00"
@.str.1 = [40 x i8] c"set_bit(0x%08x,%u,%u): 0x%08x, correct\0A\00"
define void @test_set_bit(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
store i32 %0, i32* %5
%6 = call i32 @set_bit(i32* %5, i32 %1, i32 %2)
%7 = load i32, i32* %5
%8 = icmp eq i32 %7, %3
br i1 %8, label %11, label %9
9: ; preds = %4
%10 = call i32 (i8*, i32, i32, i32, i32, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0), i32 %0, i32 %1, i32 %2, i32 %7, i32 %3)
br label %13
11: ; preds = %4
%12 = call i32 (i8*, i32, i32, i32, i32, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0), i32 %0, i32 %1, i32 %2, i32 %3)
br label %13
13: ; preds = %11, %9
ret void
}