#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 */
struct A {
  short ia;
  unsigned char *ca;
};
typedef int /*<<< orphan*/ b;

/* Variables and functions */
int EXIT_SUCCESS;
int /*<<< orphan*/ print_bit(void *, int);
int /*<<< orphan*/ printf(char *, unsigned char, ...);
int /*<<< orphan*/ test_unsigned_and_signed();
int main(void) {
  test_unsigned_and_signed();
  printf("%d\n", sizeof(long));
  unsigned char a = 336;
  print_bit((void *)&a, sizeof(char));
  print_bit((void *)&a, sizeof(short));
  printf("%d\n", a);
  int *p = &a;
  print_bit((void *)p, sizeof(int));
  printf("%d\n", *p);
  unsigned char b = -1;
  print_bit((void *)&b, sizeof(b));
  printf("%d\n", b);
  union A {
    short ia;
    unsigned char ca[2];
  } aa;
  aa.ia = 336;
  printf("%d %d\n", aa.ca[0], aa.ca[1]);
  aa.ca[0] = 336;
  printf("%d %d\n", aa.ca[0], aa.ca[1]);
  aa.ca[1] = 336;
  printf("%d %d\n", aa.ca[0], aa.ca[1]);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1050 <test_unsigned_and_signed@plt>
lea    0xeb6(%rip),%rdi
mov    $0x8,%esi
mov    $0x0,%al
call   1030 <printf@plt>
movb   $0x50,-0x5(%rbp)
lea    -0x5(%rbp),%rdi
mov    $0x1,%esi
call   1040 <print_bit@plt>
lea    -0x5(%rbp),%rdi
mov    $0x2,%esi
call   1040 <print_bit@plt>
lea    0xe83(%rip),%rdi
movzbl -0x5(%rbp),%esi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x5(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x4,%esi
call   1040 <print_bit@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
lea    0xe55(%rip),%rdi
movzbl %al,%esi
mov    $0x0,%al
call   1030 <printf@plt>
movb   $0xff,-0x11(%rbp)
lea    -0x11(%rbp),%rdi
mov    $0x1,%esi
call   1040 <print_bit@plt>
lea    0xe32(%rip),%rdi
movzbl -0x11(%rbp),%esi
mov    $0x0,%al
call   1030 <printf@plt>
movw   $0x150,-0x18(%rbp)
mov    -0x18(%rbp),%al
movzbl -0x17(%rbp),%edx
lea    0xe10(%rip),%rdi
movzbl %al,%esi
mov    $0x0,%al
call   1030 <printf@plt>
movb   $0x50,-0x18(%rbp)
mov    -0x18(%rbp),%al
movzbl -0x17(%rbp),%edx
lea    0xdf4(%rip),%rdi
movzbl %al,%esi
mov    $0x0,%al
call   1030 <printf@plt>
movb   $0x50,-0x17(%rbp)
mov    -0x18(%rbp),%al
movzbl -0x17(%rbp),%edx
lea    0xdd8(%rip),%rdi
movzbl %al,%esi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2da7(%rip),%rax
mov    (%rax),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1050 <test_unsigned_and_signed@plt>
lea    0xec1(%rip),%r14
mov    %r14,%rdi
mov    $0x8,%esi
xor    %eax,%eax
call   1030 <printf@plt>
movb   $0x50,0x4(%rsp)
lea    0x4(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x1,%esi
call   1040 <print_bit@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
call   1040 <print_bit@plt>
movzbl 0x4(%rsp),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
call   1040 <print_bit@plt>
movzbl 0x4(%rsp),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
movb   $0xff,0x7(%rsp)
lea    0x7(%rsp),%rdi
mov    $0x1,%esi
call   1040 <print_bit@plt>
movzbl 0x7(%rsp),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe36(%rip),%rbx
mov    %rbx,%rdi
mov    $0x50,%esi
mov    $0x1,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x50,%esi
mov    $0x1,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x50,%esi
mov    $0x50,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x2dd3(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%union.A = type { i16 }
@.str = [4 x i8] c"%d\0A\00"
@.str.1 = [7 x i8] c"%d %d\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i32*
%4 = alloca i8
%5 = alloca %union.A
store i32 0, i32* %1
%6 = call i32 (...) @test_unsigned_and_signed()
%7 = call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 zeroext 8)
store i8 80, i8* %2
%8 = call i32 @print_bit(i8* %2, i32 1)
%9 = call i32 @print_bit(i8* %2, i32 2)
%10 = load i8, i8* %2
%11 = call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 zeroext %10)
%12 = bitcast i8* %2 to i32*
store i32* %12, i32** %3
%13 = load i32*, i32** %3
%14 = bitcast i32* %13 to i8*
%15 = call i32 @print_bit(i8* %14, i32 4)
%16 = load i32*, i32** %3
%17 = load i32, i32* %16
%18 = trunc i32 %17 to i8
%19 = call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 zeroext %18)
store i8 -1, i8* %4
%20 = call i32 @print_bit(i8* %4, i32 1)
%21 = load i8, i8* %4
%22 = call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 zeroext %21)
%23 = bitcast %union.A* %5 to i16*
store i16 336, i16* %23
%24 = bitcast %union.A* %5 to [2 x i8]*
%25 = getelementptr inbounds [2 x i8], [2 x i8]* %24, i64 0, i64 0
%26 = load i8, i8* %25
%27 = bitcast %union.A* %5 to [2 x i8]*
%28 = getelementptr inbounds [2 x i8], [2 x i8]* %27, i64 0, i64 1
%29 = load i8, i8* %28
%30 = zext i8 %29 to i32
%31 = call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %26, i32 %30)
%32 = bitcast %union.A* %5 to [2 x i8]*
%33 = getelementptr inbounds [2 x i8], [2 x i8]* %32, i64 0, i64 0
store i8 80, i8* %33
%34 = bitcast %union.A* %5 to [2 x i8]*
%35 = getelementptr inbounds [2 x i8], [2 x i8]* %34, i64 0, i64 0
%36 = load i8, i8* %35
%37 = bitcast %union.A* %5 to [2 x i8]*
%38 = getelementptr inbounds [2 x i8], [2 x i8]* %37, i64 0, i64 1
%39 = load i8, i8* %38
%40 = zext i8 %39 to i32
%41 = call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %36, i32 %40)
%42 = bitcast %union.A* %5 to [2 x i8]*
%43 = getelementptr inbounds [2 x i8], [2 x i8]* %42, i64 0, i64 1
store i8 80, i8* %43
%44 = bitcast %union.A* %5 to [2 x i8]*
%45 = getelementptr inbounds [2 x i8], [2 x i8]* %44, i64 0, i64 0
%46 = load i8, i8* %45
%47 = bitcast %union.A* %5 to [2 x i8]*
%48 = getelementptr inbounds [2 x i8], [2 x i8]* %47, i64 0, i64 1
%49 = load i8, i8* %48
%50 = zext i8 %49 to i32
%51 = call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %46, i32 %50)
%52 = load i32, i32* @EXIT_SUCCESS
ret i32 %52
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
@.str.1 = [7 x i8] c"%d %d\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i8
%2 = alloca i8
%3 = tail call i32 (...) @test_unsigned_and_signed()
%4 = tail call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 zeroext 8)
store i8 80, i8* %1
%5 = call i32 @print_bit(i8* %1, i32 1)
%6 = call i32 @print_bit(i8* %1, i32 2)
%7 = load i8, i8* %1
%8 = call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 zeroext %7)
%9 = bitcast i8* %1 to i32*
%10 = call i32 @print_bit(i8* %1, i32 4)
%11 = load i32, i32* %9
%12 = trunc i32 %11 to i8
%13 = call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 zeroext %12)
store i8 -1, i8* %2
%14 = call i32 @print_bit(i8* %2, i32 1)
%15 = load i8, i8* %2
%16 = call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8 zeroext %15)
%17 = call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8 zeroext 80, i32 1)
%18 = call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8 zeroext 80, i32 1)
%19 = call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8 zeroext 80, i32 80)
%20 = load i32, i32* @EXIT_SUCCESS
ret i32 %20
}