#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*/ free(void *);
void *test(int);
int do_test(void) {
  void *p;
  int ret = 0;
  p = test(2);
  ret |= (unsigned long)p & (16 - 1);
  free(p);
  p = test(8);
  ret |= (unsigned long)p & (16 - 1);
  free(p);
  p = test(13);
  ret |= (unsigned long)p & (16 - 1);
  free(p);
  p = test(16);
  ret |= (unsigned long)p & (16 - 1);
  free(p);
  p = test(23);
  ret |= (unsigned long)p & (16 - 1);
  free(p);
  p = test(43);
  ret |= (unsigned long)p & (16 - 1);
  free(p);
  p = test(123);
  ret |= (unsigned long)p & (16 - 1);
  free(p);
  return ret;
}


x86 assembly (clang, -O0):
<do_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0xc(%rbp)
mov    $0x2,%edi
call   1040 <test@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rcx
and    $0xf,%rcx
movslq -0xc(%rbp),%rax
or     %rcx,%rax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
mov    $0x8,%edi
call   1040 <test@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rcx
and    $0xf,%rcx
movslq -0xc(%rbp),%rax
or     %rcx,%rax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
mov    $0xd,%edi
call   1040 <test@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rcx
and    $0xf,%rcx
movslq -0xc(%rbp),%rax
or     %rcx,%rax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
mov    $0x10,%edi
call   1040 <test@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rcx
and    $0xf,%rcx
movslq -0xc(%rbp),%rax
or     %rcx,%rax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
mov    $0x17,%edi
call   1040 <test@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rcx
and    $0xf,%rcx
movslq -0xc(%rbp),%rax
or     %rcx,%rax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
mov    $0x2b,%edi
call   1040 <test@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rcx
and    $0xf,%rcx
movslq -0xc(%rbp),%rax
or     %rcx,%rax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
mov    $0x7b,%edi
call   1040 <test@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rcx
and    $0xf,%rcx
movslq -0xc(%rbp),%rax
or     %rcx,%rax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_test>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    $0x2,%edi
call   1040 <test@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1030 <free@plt>
mov    $0x8,%edi
call   1040 <test@plt>
or     %eax,%ebx
mov    %rax,%rdi
call   1030 <free@plt>
mov    $0xd,%edi
call   1040 <test@plt>
mov    %rax,%r14
mov    %rax,%rdi
call   1030 <free@plt>
mov    $0x10,%edi
call   1040 <test@plt>
mov    %eax,%r15d
or     %r14d,%r15d
or     %ebx,%r15d
mov    %rax,%rdi
call   1030 <free@plt>
mov    $0x17,%edi
call   1040 <test@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1030 <free@plt>
mov    $0x2b,%edi
call   1040 <test@plt>
mov    %eax,%ebp
or     %ebx,%ebp
mov    %rax,%rdi
call   1030 <free@plt>
mov    $0x7b,%edi
call   1040 <test@plt>
mov    %eax,%ebx
or     %ebp,%ebx
or     %r15d,%ebx
and    $0xf,%ebx
mov    %rax,%rdi
call   1030 <free@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @do_test() {
%1 = alloca i8*
%2 = alloca i32
store i32 0, i32* %2
%3 = call i8* @test(i32 2)
store i8* %3, i8** %1
%4 = load i8*, i8** %1
%5 = ptrtoint i8* %4 to i64
%6 = and i64 %5, 15
%7 = load i32, i32* %2
%8 = sext i32 %7 to i64
%9 = or i64 %8, %6
%10 = trunc i64 %9 to i32
store i32 %10, i32* %2
%11 = load i8*, i8** %1
%12 = call i32 @free(i8* %11)
%13 = call i8* @test(i32 8)
store i8* %13, i8** %1
%14 = load i8*, i8** %1
%15 = ptrtoint i8* %14 to i64
%16 = and i64 %15, 15
%17 = load i32, i32* %2
%18 = sext i32 %17 to i64
%19 = or i64 %18, %16
%20 = trunc i64 %19 to i32
store i32 %20, i32* %2
%21 = load i8*, i8** %1
%22 = call i32 @free(i8* %21)
%23 = call i8* @test(i32 13)
store i8* %23, i8** %1
%24 = load i8*, i8** %1
%25 = ptrtoint i8* %24 to i64
%26 = and i64 %25, 15
%27 = load i32, i32* %2
%28 = sext i32 %27 to i64
%29 = or i64 %28, %26
%30 = trunc i64 %29 to i32
store i32 %30, i32* %2
%31 = load i8*, i8** %1
%32 = call i32 @free(i8* %31)
%33 = call i8* @test(i32 16)
store i8* %33, i8** %1
%34 = load i8*, i8** %1
%35 = ptrtoint i8* %34 to i64
%36 = and i64 %35, 15
%37 = load i32, i32* %2
%38 = sext i32 %37 to i64
%39 = or i64 %38, %36
%40 = trunc i64 %39 to i32
store i32 %40, i32* %2
%41 = load i8*, i8** %1
%42 = call i32 @free(i8* %41)
%43 = call i8* @test(i32 23)
store i8* %43, i8** %1
%44 = load i8*, i8** %1
%45 = ptrtoint i8* %44 to i64
%46 = and i64 %45, 15
%47 = load i32, i32* %2
%48 = sext i32 %47 to i64
%49 = or i64 %48, %46
%50 = trunc i64 %49 to i32
store i32 %50, i32* %2
%51 = load i8*, i8** %1
%52 = call i32 @free(i8* %51)
%53 = call i8* @test(i32 43)
store i8* %53, i8** %1
%54 = load i8*, i8** %1
%55 = ptrtoint i8* %54 to i64
%56 = and i64 %55, 15
%57 = load i32, i32* %2
%58 = sext i32 %57 to i64
%59 = or i64 %58, %56
%60 = trunc i64 %59 to i32
store i32 %60, i32* %2
%61 = load i8*, i8** %1
%62 = call i32 @free(i8* %61)
%63 = call i8* @test(i32 123)
store i8* %63, i8** %1
%64 = load i8*, i8** %1
%65 = ptrtoint i8* %64 to i64
%66 = and i64 %65, 15
%67 = load i32, i32* %2
%68 = sext i32 %67 to i64
%69 = or i64 %68, %66
%70 = trunc i64 %69 to i32
store i32 %70, i32* %2
%71 = load i8*, i8** %1
%72 = call i32 @free(i8* %71)
%73 = load i32, i32* %2
ret i32 %73
}

LLVM IR (-O2):
define i32 @do_test() {
%1 = tail call i8* @test(i32 2)
%2 = ptrtoint i8* %1 to i64
%3 = tail call i32 @free(i8* %1)
%4 = tail call i8* @test(i32 8)
%5 = ptrtoint i8* %4 to i64
%6 = or i64 %5, %2
%7 = tail call i32 @free(i8* %4)
%8 = tail call i8* @test(i32 13)
%9 = ptrtoint i8* %8 to i64
%10 = or i64 %6, %9
%11 = tail call i32 @free(i8* %8)
%12 = tail call i8* @test(i32 16)
%13 = ptrtoint i8* %12 to i64
%14 = or i64 %10, %13
%15 = tail call i32 @free(i8* %12)
%16 = tail call i8* @test(i32 23)
%17 = ptrtoint i8* %16 to i64
%18 = or i64 %14, %17
%19 = tail call i32 @free(i8* %16)
%20 = tail call i8* @test(i32 43)
%21 = ptrtoint i8* %20 to i64
%22 = or i64 %18, %21
%23 = tail call i32 @free(i8* %20)
%24 = tail call i8* @test(i32 123)
%25 = ptrtoint i8* %24 to i64
%26 = or i64 %22, %25
%27 = trunc i64 %26 to i32
%28 = and i32 %27, 15
%29 = tail call i32 @free(i8* %24)
ret i32 %28
}