#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 */
typedef int uint8_t;

/* Variables and functions */
int /*<<< orphan*/ sprintf(char *, char *, int, ...);
void sprint_mov_to_bit(char *str, uint8_t bit) {
  if (bit & 0x80)
    sprintf(str,
            "MOV   "
            "0x%02X"
            ".%X, C                 ",
            bit & 0xF8, bit & 0x07);
  else
    sprintf(str,
            "MOV   "
            "0x%02X"
            ", C                   ",
            bit);
}


x86 assembly (clang, -O0):
<sprint_mov_to_bit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
and    $0x80,%eax
cmp    $0x0,%eax
je     1156 <sprint_mov_to_bit+0x46>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
and    $0xf8,%edx
mov    -0xc(%rbp),%ecx
and    $0x7,%ecx
lea    0xeb6(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
jmp    116b <sprint_mov_to_bit+0x5b>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
lea    0xec0(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sprint_mov_to_bit>:
mov    %esi,%ecx
test   $0x80,%cl
jne    1127 <sprint_mov_to_bit+0x17>
lea    0xf06(%rip),%rsi
mov    %ecx,%edx
xor    %eax,%eax
jmp    1030 <sprintf@plt>
mov    %ecx,%edx
and    $0xf8,%edx
and    $0x7,%ecx
lea    0xec7(%rip),%rsi
xor    %eax,%eax
jmp    1030 <sprintf@plt>

LLVM IR (-O0):
@.str = [36 x i8] c"MOV 0x%02X.%X, C \00"
@.str.1 = [35 x i8] c"MOV 0x%02X, C \00"
define void @sprint_mov_to_bit(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%5 = load i32, i32* %4
%6 = and i32 %5, 128
%7 = icmp ne i32 %6, 0
br i1 %7, label %8, label %15
8: ; preds = %2
%9 = load i8*, i8** %3
%10 = load i32, i32* %4
%11 = and i32 %10, 248
%12 = load i32, i32* %4
%13 = and i32 %12, 7
%14 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %9, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 %11, i32 %13)
br label %19
15: ; preds = %2
%16 = load i8*, i8** %3
%17 = load i32, i32* %4
%18 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %16, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i32 %17)
br label %19
19: ; preds = %15, %8
ret void
}

LLVM IR (-O2):
@.str = [36 x i8] c"MOV 0x%02X.%X, C \00"
@.str.1 = [35 x i8] c"MOV 0x%02X, C \00"
define void @sprint_mov_to_bit(i8* nocapture writeonly %0, i32 %1) {
%3 = and i32 %1, 128
%4 = icmp eq i32 %3, 0
br i1 %4, label %9, label %5
5: ; preds = %2
%6 = and i32 %1, 248
%7 = and i32 %1, 7
%8 = tail call i32 (i8*, i8*, i32, ...) @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 %6, i32 %7)
br label %11
9: ; preds = %2
%10 = tail call i32 (i8*, i8*, i32, ...) @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i32 %1)
br label %11
11: ; preds = %9, %5
ret void
}