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


x86 assembly (clang, -O0):
<test_flip_bit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%esi
lea    -0x4(%rbp),%rdi
call   1030 <flip_bit@plt>
mov    -0x4(%rbp),%eax
cmp    -0xc(%rbp),%eax
je     116f <test_flip_bit+0x4f>
mov    -0x10(%rbp),%esi
mov    -0x8(%rbp),%edx
mov    -0x4(%rbp),%ecx
mov    -0xc(%rbp),%r8d
lea    0xe9d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1186 <test_flip_bit+0x66>
mov    -0x10(%rbp),%esi
mov    -0x8(%rbp),%edx
mov    -0x4(%rbp),%ecx
lea    0xeaf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_flip_bit>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %edx,%r14d
mov    %esi,%ebp
mov    %edi,%ebx
mov    %edi,0xc(%rsp)
lea    0xc(%rsp),%rdi
call   1030 <flip_bit@plt>
mov    0xc(%rsp),%ecx
cmp    %r14d,%ecx
jne    115d <test_flip_bit+0x3d>
lea    0xee1(%rip),%rdi
mov    %ebx,%esi
mov    %ebp,%edx
mov    %r14d,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1172 <test_flip_bit+0x52>
lea    0xe9c(%rip),%rdi
mov    %ebx,%esi
mov    %ebp,%edx
mov    %r14d,%r8d
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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