#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 EXIT_FAILURE;
int EXIT_SUCCESS;
scalar_t__ auto_clean_add(char *, int /*<<< orphan*/ (*)(char *));
int /*<<< orphan*/ auto_clean_init();
int /*<<< orphan*/ free(char *);
char *malloc(int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, unsigned char, char);
int main(void) {
  char *testptr = malloc(256);
  int i;
  auto_clean_init();
  if (testptr == NULL) {
    perror("malloc");
    return EXIT_FAILURE;
  }
  if (auto_clean_add(testptr, free) < 0) {
    free(testptr);
    return EXIT_FAILURE;
  }
  for (i = 0; i < 256; i++)
    testptr[i] = (char)i;
  for (i = 0; i < 256; i++)
    printf("%02X%c", (unsigned char)testptr[i], i % 16 == 15 ? '\n' : ' ');
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x100,%edi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    $0x0,%al
call   1060 <auto_clean_init@plt>
cmpq   $0x0,-0x10(%rbp)
jne    119c <main+0x4c>
lea    0xe7a(%rip),%rdi
call   1070 <perror@plt>
mov    0x2e4e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    126a <main+0x11a>
mov    -0x10(%rbp),%rdi
mov    0x2e21(%rip),%rsi
call   1050 <auto_clean_add@plt>
cmp    $0x0,%rax
jge    11d0 <main+0x80>
mov    -0x10(%rbp),%rdi
call   1080 <free@plt>
mov    0x2e1a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    126a <main+0x11a>
movl   $0x0,-0x14(%rbp)
cmpl   $0x100,-0x14(%rbp)
jge    1202 <main+0xb2>
mov    -0x14(%rbp),%eax
mov    %al,%dl
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11d7 <main+0x87>
movl   $0x0,-0x14(%rbp)
cmpl   $0x100,-0x14(%rbp)
jge    125e <main+0x10e>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,1),%cl
mov    -0x14(%rbp),%eax
mov    $0x10,%esi
cltd
idiv   %esi
mov    %edx,%esi
mov    $0x20,%eax
mov    $0xa,%edx
cmp    $0xf,%esi
cmove  %edx,%eax
lea    0xdc2(%rip),%rdi
movzbl %cl,%esi
movsbl %al,%edx
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1209 <main+0xb9>
mov    0x2d73(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    $0x100,%edi
call   1040 <malloc@plt>
mov    %rax,%r12
xor    %eax,%eax
call   1060 <auto_clean_init@plt>
test   %r12,%r12
je     12d5 <main+0x185>
mov    0x2e4c(%rip),%rsi
mov    %r12,%rdi
call   1050 <auto_clean_add@plt>
test   %rax,%rax
js     12ba <main+0x16a>
movaps 0xe6c(%rip),%xmm0
movups %xmm0,(%r12)
movaps 0xe70(%rip),%xmm0
movups %xmm0,0x10(%r12)
movaps 0xe73(%rip),%xmm0
movups %xmm0,0x20(%r12)
movaps 0xe76(%rip),%xmm0
movups %xmm0,0x30(%r12)
movaps 0xe79(%rip),%xmm0
movups %xmm0,0x40(%r12)
movaps 0xe7c(%rip),%xmm0
movups %xmm0,0x50(%r12)
movaps 0xe7f(%rip),%xmm0
movups %xmm0,0x60(%r12)
movaps 0xe82(%rip),%xmm0
movups %xmm0,0x70(%r12)
movaps 0xe85(%rip),%xmm0
movups %xmm0,0x80(%r12)
movaps 0xe85(%rip),%xmm0
movups %xmm0,0x90(%r12)
movaps 0xe85(%rip),%xmm0
movups %xmm0,0xa0(%r12)
movaps 0xe85(%rip),%xmm0
movups %xmm0,0xb0(%r12)
movaps 0xe85(%rip),%xmm0
movups %xmm0,0xc0(%r12)
movaps 0xe85(%rip),%xmm0
movups %xmm0,0xd0(%r12)
movaps 0xe85(%rip),%xmm0
movups %xmm0,0xe0(%r12)
movaps 0xe85(%rip),%xmm0
movups %xmm0,0xf0(%r12)
xor    %ebx,%ebx
mov    $0xa,%ebp
lea    0xe85(%rip),%r14
mov    0x2d4f(%rip),%r15
nopl   0x0(%rax)
movzbl (%r12,%rbx,1),%esi
mov    %ebx,%eax
not    %eax
test   $0xf,%al
mov    $0x20,%edx
cmove  %ebp,%edx
mov    %r14,%rdi
call   1030 <printf@plt>
add    $0x1,%rbx
cmp    $0x100,%rbx
jne    1290 <main+0x140>
jmp    12c9 <main+0x179>
mov    %r12,%rdi
call   1080 <free@plt>
mov    0x2d17(%rip),%r15
mov    (%r15),%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe24(%rip),%rdi
call   1070 <perror@plt>
jmp    12c2 <main+0x172>

LLVM IR (-O0):
@.str = [7 x i8] c"malloc\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [7 x i8] c"%02X%c\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i32
store i32 0, i32* %1
%4 = call i8* @malloc(i32 256)
store i8* %4, i8** %2
%5 = call i32 (...) @auto_clean_init()
%6 = load i8*, i8** %2
%7 = icmp eq i8* %6, null
br i1 %7, label %8, label %11
8: ; preds = %0
%9 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%10 = load i32, i32* @EXIT_FAILURE
store i32 %10, i32* %1
br label %55
11: ; preds = %0
%12 = load i8*, i8** %2
%13 = call i64 @auto_clean_add(i8* %12, i32 (i8*)* @free)
%14 = icmp slt i64 %13, 0
br i1 %14, label %15, label %19
15: ; preds = %11
%16 = load i8*, i8** %2
%17 = call i32 @free(i8* %16)
%18 = load i32, i32* @EXIT_FAILURE
store i32 %18, i32* %1
br label %55
19: ; preds = %11
store i32 0, i32* %3
br label %20
20: ; preds = %30, %19
%21 = load i32, i32* %3
%22 = icmp slt i32 %21, 256
br i1 %22, label %23, label %33
23: ; preds = %20
%24 = load i32, i32* %3
%25 = trunc i32 %24 to i8
%26 = load i8*, i8** %2
%27 = load i32, i32* %3
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %26, i64 %28
store i8 %25, i8* %29
br label %30
30: ; preds = %23
%31 = load i32, i32* %3
%32 = add nsw i32 %31, 1
store i32 %32, i32* %3
br label %20
33: ; preds = %20
store i32 0, i32* %3
br label %34
34: ; preds = %50, %33
%35 = load i32, i32* %3
%36 = icmp slt i32 %35, 256
br i1 %36, label %37, label %53
37: ; preds = %34
%38 = load i8*, i8** %2
%39 = load i32, i32* %3
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8, i8* %38, i64 %40
%42 = load i8, i8* %41
%43 = load i32, i32* %3
%44 = srem i32 %43, 16
%45 = icmp eq i32 %44, 15
%46 = zext i1 %45 to i64
%47 = select i1 %45, i32 10, i32 32
%48 = trunc i32 %47 to i8
%49 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %42, i8 signext %48)
br label %50
50: ; preds = %37
%51 = load i32, i32* %3
%52 = add nsw i32 %51, 1
store i32 %52, i32* %3
br label %34
53: ; preds = %34
%54 = load i32, i32* @EXIT_SUCCESS
store i32 %54, i32* %1
br label %55
55: ; preds = %53, %15, %8
%56 = load i32, i32* %1
ret i32 %56
}

LLVM IR (-O2):
@.str = [7 x i8] c"malloc\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [7 x i8] c"%02X%c\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = tail call dereferenceable_or_null(256) i8* @malloc(i32 256)
%2 = tail call i32 (...) @auto_clean_init()
%3 = icmp eq i8* %1, null
br i1 %3, label %4, label %6
4: ; preds = %0
%5 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
br label %53
6: ; preds = %0
%7 = tail call i64 @auto_clean_add(i8* %1, i32 (i8*)* @free)
%8 = icmp slt i64 %7, 0
br i1 %8, label %41, label %9
9: ; preds = %6
%10 = bitcast i8* %1 to <16 x i8>*
store <16 x i8> <i8 0, i8 1, i8 2, i8 3, i8 4, i8 5, i8 6, i8 7, i8 8, i8 9, i8 10, i8 11, i8 12, i8 13, i8 14, i8 15>, <16 x i8>* %10
%11 = getelementptr inbounds i8, i8* %1, i64 16
%12 = bitcast i8* %11 to <16 x i8>*
store <16 x i8> <i8 16, i8 17, i8 18, i8 19, i8 20, i8 21, i8 22, i8 23, i8 24, i8 25, i8 26, i8 27, i8 28, i8 29, i8 30, i8 31>, <16 x i8>* %12
%13 = getelementptr inbounds i8, i8* %1, i64 32
%14 = bitcast i8* %13 to <16 x i8>*
store <16 x i8> <i8 32, i8 33, i8 34, i8 35, i8 36, i8 37, i8 38, i8 39, i8 40, i8 41, i8 42, i8 43, i8 44, i8 45, i8 46, i8 47>, <16 x i8>* %14
%15 = getelementptr inbounds i8, i8* %1, i64 48
%16 = bitcast i8* %15 to <16 x i8>*
store <16 x i8> <i8 48, i8 49, i8 50, i8 51, i8 52, i8 53, i8 54, i8 55, i8 56, i8 57, i8 58, i8 59, i8 60, i8 61, i8 62, i8 63>, <16 x i8>* %16
%17 = getelementptr inbounds i8, i8* %1, i64 64
%18 = bitcast i8* %17 to <16 x i8>*
store <16 x i8> <i8 64, i8 65, i8 66, i8 67, i8 68, i8 69, i8 70, i8 71, i8 72, i8 73, i8 74, i8 75, i8 76, i8 77, i8 78, i8 79>, <16 x i8>* %18
%19 = getelementptr inbounds i8, i8* %1, i64 80
%20 = bitcast i8* %19 to <16 x i8>*
store <16 x i8> <i8 80, i8 81, i8 82, i8 83, i8 84, i8 85, i8 86, i8 87, i8 88, i8 89, i8 90, i8 91, i8 92, i8 93, i8 94, i8 95>, <16 x i8>* %20
%21 = getelementptr inbounds i8, i8* %1, i64 96
%22 = bitcast i8* %21 to <16 x i8>*
store <16 x i8> <i8 96, i8 97, i8 98, i8 99, i8 100, i8 101, i8 102, i8 103, i8 104, i8 105, i8 106, i8 107, i8 108, i8 109, i8 110, i8 111>, <16 x i8>* %22
%23 = getelementptr inbounds i8, i8* %1, i64 112
%24 = bitcast i8* %23 to <16 x i8>*
store <16 x i8> <i8 112, i8 113, i8 114, i8 115, i8 116, i8 117, i8 118, i8 119, i8 120, i8 121, i8 122, i8 123, i8 124, i8 125, i8 126, i8 127>, <16 x i8>* %24
%25 = getelementptr inbounds i8, i8* %1, i64 128
%26 = bitcast i8* %25 to <16 x i8>*
store <16 x i8> <i8 -128, i8 -127, i8 -126, i8 -125, i8 -124, i8 -123, i8 -122, i8 -121, i8 -120, i8 -119, i8 -118, i8 -117, i8 -116, i8 -115, i8 -114, i8 -113>, <16 x i8>* %26
%27 = getelementptr inbounds i8, i8* %1, i64 144
%28 = bitcast i8* %27 to <16 x i8>*
store <16 x i8> <i8 -112, i8 -111, i8 -110, i8 -109, i8 -108, i8 -107, i8 -106, i8 -105, i8 -104, i8 -103, i8 -102, i8 -101, i8 -100, i8 -99, i8 -98, i8 -97>, <16 x i8>* %28
%29 = getelementptr inbounds i8, i8* %1, i64 160
%30 = bitcast i8* %29 to <16 x i8>*
store <16 x i8> <i8 -96, i8 -95, i8 -94, i8 -93, i8 -92, i8 -91, i8 -90, i8 -89, i8 -88, i8 -87, i8 -86, i8 -85, i8 -84, i8 -83, i8 -82, i8 -81>, <16 x i8>* %30
%31 = getelementptr inbounds i8, i8* %1, i64 176
%32 = bitcast i8* %31 to <16 x i8>*
store <16 x i8> <i8 -80, i8 -79, i8 -78, i8 -77, i8 -76, i8 -75, i8 -74, i8 -73, i8 -72, i8 -71, i8 -70, i8 -69, i8 -68, i8 -67, i8 -66, i8 -65>, <16 x i8>* %32
%33 = getelementptr inbounds i8, i8* %1, i64 192
%34 = bitcast i8* %33 to <16 x i8>*
store <16 x i8> <i8 -64, i8 -63, i8 -62, i8 -61, i8 -60, i8 -59, i8 -58, i8 -57, i8 -56, i8 -55, i8 -54, i8 -53, i8 -52, i8 -51, i8 -50, i8 -49>, <16 x i8>* %34
%35 = getelementptr inbounds i8, i8* %1, i64 208
%36 = bitcast i8* %35 to <16 x i8>*
store <16 x i8> <i8 -48, i8 -47, i8 -46, i8 -45, i8 -44, i8 -43, i8 -42, i8 -41, i8 -40, i8 -39, i8 -38, i8 -37, i8 -36, i8 -35, i8 -34, i8 -33>, <16 x i8>* %36
%37 = getelementptr inbounds i8, i8* %1, i64 224
%38 = bitcast i8* %37 to <16 x i8>*
store <16 x i8> <i8 -32, i8 -31, i8 -30, i8 -29, i8 -28, i8 -27, i8 -26, i8 -25, i8 -24, i8 -23, i8 -22, i8 -21, i8 -20, i8 -19, i8 -18, i8 -17>, <16 x i8>* %38
%39 = getelementptr inbounds i8, i8* %1, i64 240
%40 = bitcast i8* %39 to <16 x i8>*
store <16 x i8> <i8 -16, i8 -15, i8 -14, i8 -13, i8 -12, i8 -11, i8 -10, i8 -9, i8 -8, i8 -7, i8 -6, i8 -5, i8 -4, i8 -3, i8 -2, i8 -1>, <16 x i8>* %40
br label %43
41: ; preds = %6
%42 = tail call i32 @free(i8* %1)
br label %53
43: ; preds = %9, %43
%44 = phi i64 [ %51, %43 ], [ 0, %9 ]
%45 = getelementptr inbounds i8, i8* %1, i64 %44
%46 = load i8, i8* %45
%47 = and i64 %44, 15
%48 = icmp eq i64 %47, 15
%49 = select i1 %48, i8 10, i8 32
%50 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8 zeroext %46, i8 signext %49)
%51 = add nuw nsw i64 %44, 1
%52 = icmp eq i64 %51, 256
br i1 %52, label %53, label %43
53: ; preds = %43, %41, %4
%54 = phi i32* [ @EXIT_FAILURE, %4 ], [ @EXIT_FAILURE, %41 ], [ @EXIT_SUCCESS, %43 ]
%55 = load i32, i32* %54
ret i32 %55
}