#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;
typedef int uint32_t;
typedef int uint16_t;
typedef int /*<<< orphan*/ buffer;

/* Variables and functions */
int get16(int **);
int get32(int **);
int get8(int **);
int /*<<< orphan*/ memset(int *, int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ put16(int **, int);
int /*<<< orphan*/ put32(int **, int);
int /*<<< orphan*/ put8(int **, int);
void test1(void) {
  uint8_t buffer[16];
  uint8_t *pb = buffer;
  memset(buffer, 0xFF, sizeof(buffer));
  put8(&pb, 0x01);
  put16(&pb, 0x0203);
  put32(&pb, 0x04050607);
  int i;
  for (i = 0; i < 7; i++) {
    printf(" %02X", buffer[i]);
  }
  printf("\n");
  pb = buffer;
  uint8_t b = get8(&pb);
  uint16_t w = get16(&pb);
  uint32_t l = get32(&pb);
  printf("b = %02X\n", b);
  printf("w = %04X\n", w);
  printf("l = %08X\n", l);
}


x86 assembly (clang, -O0):
<test1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
lea    -0x40(%rbp),%rax
mov    %rax,-0x48(%rbp)
lea    -0x40(%rbp),%rdi
mov    $0xff,%esi
mov    $0x40,%edx
call   1070 <memset@plt>
lea    -0x48(%rbp),%rdi
mov    $0x1,%esi
call   1030 <put8@plt>
lea    -0x48(%rbp),%rdi
mov    $0x203,%esi
call   1060 <put16@plt>
lea    -0x48(%rbp),%rdi
mov    $0x4050607,%esi
call   1080 <put32@plt>
movl   $0x0,-0x4c(%rbp)
cmpl   $0x7,-0x4c(%rbp)
jge    1202 <test1+0x82>
movslq -0x4c(%rbp),%rax
mov    -0x40(%rbp,%rax,4),%esi
lea    0xe13(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    11d4 <test1+0x54>
lea    0xe05(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x40(%rbp),%rax
mov    %rax,-0x48(%rbp)
lea    -0x48(%rbp),%rdi
call   1040 <get8@plt>
mov    %eax,-0x50(%rbp)
lea    -0x48(%rbp),%rdi
call   10a0 <get16@plt>
mov    %eax,-0x54(%rbp)
lea    -0x48(%rbp),%rdi
call   1090 <get32@plt>
mov    %eax,-0x58(%rbp)
mov    -0x50(%rbp),%esi
lea    0xdc0(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x54(%rbp),%esi
lea    0xdb9(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x58(%rbp),%esi
lea    0xdb2(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test1>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x58,%rsp
lea    0x10(%rsp),%r14
mov    %r14,0x8(%rsp)
mov    %r14,%rdi
mov    $0xff,%esi
mov    $0x40,%edx
call   1080 <memset@plt>
lea    0x8(%rsp),%r15
mov    %r15,%rdi
mov    $0x1,%esi
call   1030 <put8@plt>
mov    %r15,%rdi
mov    $0x203,%esi
call   1070 <put16@plt>
mov    %r15,%rdi
mov    $0x4050607,%esi
call   1090 <put32@plt>
mov    0x10(%rsp),%esi
lea    0xe13(%rip),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x14(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x18(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x1c(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x20(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x24(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x28(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    %r14,0x8(%rsp)
mov    %r15,%rdi
call   1050 <get8@plt>
mov    %eax,%ebx
mov    %r15,%rdi
call   10b0 <get16@plt>
mov    %eax,%ebp
mov    %r15,%rdi
call   10a0 <get32@plt>
mov    %eax,%r14d
lea    0xd86(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xd80(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xd7a(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0x58,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c" %02X\00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [10 x i8] c"b = %02X\0A\00"
@.str.3 = [10 x i8] c"w = %04X\0A\00"
@.str.4 = [10 x i8] c"l = %08X\0A\00"
define void @test1() {
%1 = alloca [16 x i32]
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = getelementptr inbounds [16 x i32], [16 x i32]* %1, i64 0, i64 0
store i32* %7, i32** %2
%8 = getelementptr inbounds [16 x i32], [16 x i32]* %1, i64 0, i64 0
%9 = call i32 @memset(i32* %8, i32 255, i32 64)
%10 = call i32 @put8(i32** %2, i32 1)
%11 = call i32 @put16(i32** %2, i32 515)
%12 = call i32 @put32(i32** %2, i32 67438087)
store i32 0, i32* %3
br label %13
13: ; preds = %22, %0
%14 = load i32, i32* %3
%15 = icmp slt i32 %14, 7
br i1 %15, label %16, label %25
16: ; preds = %13
%17 = load i32, i32* %3
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [16 x i32], [16 x i32]* %1, i64 0, i64 %18
%20 = load i32, i32* %19
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %20)
br label %22
22: ; preds = %16
%23 = load i32, i32* %3
%24 = add nsw i32 %23, 1
store i32 %24, i32* %3
br label %13
25: ; preds = %13
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%27 = getelementptr inbounds [16 x i32], [16 x i32]* %1, i64 0, i64 0
store i32* %27, i32** %2
%28 = call i32 @get8(i32** %2)
store i32 %28, i32* %4
%29 = call i32 @get16(i32** %2)
store i32 %29, i32* %5
%30 = call i32 @get32(i32** %2)
store i32 %30, i32* %6
%31 = load i32, i32* %4
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %31)
%33 = load i32, i32* %5
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 %33)
%35 = load i32, i32* %6
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i32 %35)
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c" %02X\00"
@.str.2 = [10 x i8] c"b = %02X\0A\00"
@.str.3 = [10 x i8] c"w = %04X\0A\00"
@.str.4 = [10 x i8] c"l = %08X\0A\00"
define void @test1() {
%1 = alloca [16 x i32]
%2 = alloca i32*
%3 = bitcast [16 x i32]* %1 to i8*
%4 = bitcast i32** %2 to i8*
%5 = getelementptr inbounds [16 x i32], [16 x i32]* %1, i64 0, i64 0
store i32* %5, i32** %2
%6 = call i32 @memset(i32* %5, i32 255, i32 64)
%7 = call i32 @put8(i32** %2, i32 1)
%8 = call i32 @put16(i32** %2, i32 515)
%9 = call i32 @put32(i32** %2, i32 67438087)
%10 = load i32, i32* %5
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = getelementptr inbounds [16 x i32], [16 x i32]* %1, i64 0, i64 1
%13 = load i32, i32* %12
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %13)
%15 = getelementptr inbounds [16 x i32], [16 x i32]* %1, i64 0, i64 2
%16 = load i32, i32* %15
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %16)
%18 = getelementptr inbounds [16 x i32], [16 x i32]* %1, i64 0, i64 3
%19 = load i32, i32* %18
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %19)
%21 = getelementptr inbounds [16 x i32], [16 x i32]* %1, i64 0, i64 4
%22 = load i32, i32* %21
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %22)
%24 = getelementptr inbounds [16 x i32], [16 x i32]* %1, i64 0, i64 5
%25 = load i32, i32* %24
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %25)
%27 = getelementptr inbounds [16 x i32], [16 x i32]* %1, i64 0, i64 6
%28 = load i32, i32* %27
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %28)
%30 = call i32 @putchar(i32 10)
store i32* %5, i32** %2
%31 = call i32 @get8(i32** %2)
%32 = call i32 @get16(i32** %2)
%33 = call i32 @get32(i32** %2)
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %31)
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 %32)
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i32 %33)
ret void
}