#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 bit_get(unsigned char *, int);
int /*<<< orphan*/ bit_rot_left(unsigned char *, int, int);
int /*<<< orphan*/ bit_set(unsigned char *, int, int);
int /*<<< orphan*/ bit_xor(unsigned char *, unsigned char *, unsigned char *,
                           int);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ strcmp(char *, char *);
int main(int argc, char *argv[]) {
  unsigned char *bits1;
  unsigned char *bits2;
  unsigned char *bits3;
  unsigned char a = 'abcde';
  bits1 = &a;
  unsigned char b = 'aegh';
  bits2 = &b;
  int bit4 = 0;
  if (strcmp(argv[1], "bg") == 0) {
    bit4 = bit_get(bits1, 4);
    printf("Bit val at position 4 of string 'abcde' %2d\n", bit4);
  }
  if (strcmp(argv[1], "bs") == 0) {
    bit_set(bits1, 4, 1);
    bit4 = bit_get(bits1, 4);
    printf("New bit val at position 4 of string 'abcde' %2d\n", bit4);
  }
  if (strcmp(argv[1], "bx") == 0) {
    bit_xor(bits1, bits2, bits3, 64);
    printf("XOR-ed %s\n", bits3);
  }
  if (strcmp(argv[1], "br") == 0) {
    bit_rot_left(bits2, 16, 8);
    printf("Rotated %s\n", bits2);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movb   $0x65,-0x29(%rbp)
lea    -0x29(%rbp),%rax
mov    %rax,-0x18(%rbp)
movb   $0x68,-0x2a(%rbp)
lea    -0x2a(%rbp),%rax
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe5c(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    11d5 <main+0x75>
mov    -0x18(%rbp),%rdi
mov    $0x4,%esi
call   1040 <bit_get@plt>
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%esi
lea    0xe35(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe4c(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    1228 <main+0xc8>
mov    -0x18(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1070 <bit_set@plt>
mov    -0x18(%rbp),%rdi
mov    $0x4,%esi
call   1040 <bit_get@plt>
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%esi
lea    0xe12(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe2d(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    126e <main+0x10e>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    $0x40,%ecx
call   1080 <bit_xor@plt>
mov    -0x28(%rbp),%rsi
lea    0xe00(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdf5(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    12b1 <main+0x151>
mov    -0x20(%rbp),%rdi
mov    $0x10,%esi
mov    $0x8,%edx
call   1050 <bit_rot_left@plt>
mov    -0x20(%rbp),%rsi
lea    0xdcb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
movb   $0x65,0x6(%rsp)
movb   $0x68,0x7(%rsp)
mov    0x8(%rsi),%rdi
lea    0xe84(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
jne    11a5 <main+0x45>
lea    0x6(%rsp),%rdi
mov    $0x4,%esi
call   1040 <bit_get@plt>
lea    0xe67(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x8(%rbx),%rdi
lea    0xe80(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
jne    11ee <main+0x8e>
lea    0x6(%rsp),%r14
mov    %r14,%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1070 <bit_set@plt>
mov    %r14,%rdi
mov    $0x4,%esi
call   1040 <bit_get@plt>
lea    0xe4e(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x8(%rbx),%rdi
lea    0xe6b(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
jne    1225 <main+0xc5>
lea    0x6(%rsp),%rdi
lea    0x7(%rsp),%rsi
mov    $0x40,%ecx
call   1080 <bit_xor@plt>
lea    0xe49(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x8(%rbx),%rdi
lea    0xe42(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
jne    1262 <main+0x102>
lea    0x7(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x10,%esi
mov    $0x8,%edx
call   1050 <bit_rot_left@plt>
lea    0xe1d(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [3 x i8] c"bg\00"
@.str.1 = [45 x i8] c"Bit val at position 4 of string 'abcde' %2d\0A\00"
@.str.2 = [3 x i8] c"bs\00"
@.str.3 = [49 x i8] c"New bit val at position 4 of string 'abcde' %2d\0A\00"
@.str.4 = [3 x i8] c"bx\00"
@.str.5 = [11 x i8] c"XOR-ed %s\0A\00"
@.str.6 = [3 x i8] c"br\00"
@.str.7 = [12 x i8] c"Rotated %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8
%10 = alloca i8
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8 101, i8* %9
store i8* %9, i8** %6
store i8 104, i8* %10
store i8* %10, i8** %7
store i32 0, i32* %11
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i64 @strcmp(i8* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %22
17: ; preds = %2
%18 = load i8*, i8** %6
%19 = call i32 @bit_get(i8* %18, i32 4)
store i32 %19, i32* %11
%20 = load i32, i32* %11
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0), i32 %20)
br label %22
22: ; preds = %17, %2
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
%26 = call i64 @strcmp(i8* %25, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %35
28: ; preds = %22
%29 = load i8*, i8** %6
%30 = call i32 @bit_set(i8* %29, i32 4, i32 1)
%31 = load i8*, i8** %6
%32 = call i32 @bit_get(i8* %31, i32 4)
store i32 %32, i32* %11
%33 = load i32, i32* %11
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.3, i64 0, i64 0), i32 %33)
br label %35
35: ; preds = %28, %22
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 1
%38 = load i8*, i8** %37
%39 = call i64 @strcmp(i8* %38, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%40 = icmp eq i64 %39, 0
br i1 %40, label %41, label %48
41: ; preds = %35
%42 = load i8*, i8** %6
%43 = load i8*, i8** %7
%44 = load i8*, i8** %8
%45 = call i32 @bit_xor(i8* %42, i8* %43, i8* %44, i32 64)
%46 = load i8*, i8** %8
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i8* %46)
br label %48
48: ; preds = %41, %35
%49 = load i8**, i8*** %5
%50 = getelementptr inbounds i8*, i8** %49, i64 1
%51 = load i8*, i8** %50
%52 = call i64 @strcmp(i8* %51, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%53 = icmp eq i64 %52, 0
br i1 %53, label %54, label %59
54: ; preds = %48
%55 = load i8*, i8** %7
%56 = call i32 @bit_rot_left(i8* %55, i32 16, i32 8)
%57 = load i8*, i8** %7
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0), i8* %57)
br label %59
59: ; preds = %54, %48
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"bg\00"
@.str.1 = [45 x i8] c"Bit val at position 4 of string 'abcde' %2d\0A\00"
@.str.2 = [3 x i8] c"bs\00"
@.str.3 = [49 x i8] c"New bit val at position 4 of string 'abcde' %2d\0A\00"
@.str.4 = [3 x i8] c"bx\00"
@.str.5 = [11 x i8] c"XOR-ed %s\0A\00"
@.str.6 = [3 x i8] c"br\00"
@.str.7 = [12 x i8] c"Rotated %s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8
%4 = alloca i8
store i8 101, i8* %3
store i8 104, i8* %4
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = call i32 @bit_get(i8* %3, i32 4)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0), i32 %10)
br label %12
12: ; preds = %9, %2
%13 = load i8*, i8** %5
%14 = call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %20
16: ; preds = %12
%17 = call i32 @bit_set(i8* %3, i32 4, i32 1)
%18 = call i32 @bit_get(i8* %3, i32 4)
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str.3, i64 0, i64 0), i32 %18)
br label %20
20: ; preds = %16, %12
%21 = load i8*, i8** %5
%22 = call i64 @strcmp(i8* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %20
%25 = call i32 @bit_xor(i8* %3, i8* %4, i8* undef, i32 64)
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i8* undef)
br label %27
27: ; preds = %24, %20
%28 = load i8*, i8** %5
%29 = call i64 @strcmp(i8* %28, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %27
%32 = call i32 @bit_rot_left(i8* %4, i32 16, i32 8)
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0), i8* %4)
br label %34
34: ; preds = %31, %27
ret i32 0
}