#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 str {
  int dummy;
};
struct ptr {
  int dummy;
};

/* Variables and functions */
void *malloc(unsigned int);
int main(void) {
  struct str *pl;
  void *tmp;
  void *tmp___0;
  unsigned int __cil_tmp4;
  void *__cil_tmp5;
  unsigned int __cil_tmp6;
  unsigned int __cil_tmp7;
  unsigned int __cil_tmp8;
  unsigned int __cil_tmp9;
  unsigned int __cil_tmp10;
  struct ptr *__cil_tmp11;
  unsigned int __cil_tmp12;
  void *__cil_tmp13;
  unsigned int __cil_tmp14;
  unsigned int __cil_tmp15;
  unsigned int __cil_tmp16;
  struct ptr *__cil_tmp17;
  struct ptr **mem_18;
  struct ptr **mem_19;
  struct ptr **mem_20;
  int *mem_21;
  {
    {
      tmp = malloc(8U);
      pl = (struct str *)tmp;
    }
    {
      __cil_tmp4 = (unsigned int)pl;
      __cil_tmp5 = (void *)0;
      __cil_tmp6 = (unsigned int)__cil_tmp5;
      if (__cil_tmp6 == __cil_tmp4) {
        return (1);
      } else {
      }
    }
    {
      tmp___0 = malloc(4U);
      __cil_tmp7 = (unsigned int)pl;
      __cil_tmp8 = __cil_tmp7 + 4;
      mem_18 = (struct ptr **)__cil_tmp8;
      *mem_18 = (struct ptr *)tmp___0;
    }
    {
      __cil_tmp9 = (unsigned int)pl;
      __cil_tmp10 = __cil_tmp9 + 4;
      mem_19 = (struct ptr **)__cil_tmp10;
      __cil_tmp11 = *mem_19;
      __cil_tmp12 = (unsigned int)__cil_tmp11;
      __cil_tmp13 = (void *)0;
      __cil_tmp14 = (unsigned int)__cil_tmp13;
      if (__cil_tmp14 == __cil_tmp12) {
        return (2);
      } else {
      }
    }
    __cil_tmp15 = (unsigned int)pl;
    __cil_tmp16 = __cil_tmp15 + 4;
    mem_20 = (struct ptr **)__cil_tmp16;
    __cil_tmp17 = *mem_20;
    mem_21 = (int *)__cil_tmp17;
    *mem_21 = 1;
    return (0);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x8,%edi
call   1030 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %eax,-0x24(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x24(%rbp),%eax
jne    1166 <main+0x56>
movl   $0x1,-0x4(%rbp)
jmp    123d <main+0x12d>
jmp    116b <main+0x5b>
mov    $0x4,%edi
call   1030 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
mov    %rax,-0x80(%rbp)
mov    -0x20(%rbp),%rcx
mov    -0x80(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
mov    %eax,-0x40(%rbp)
mov    -0x40(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x44(%rbp)
mov    -0x44(%rbp),%eax
mov    %rax,-0x88(%rbp)
mov    -0x88(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rax
mov    %eax,-0x54(%rbp)
movq   $0x0,-0x60(%rbp)
mov    -0x60(%rbp),%rax
mov    %eax,-0x64(%rbp)
mov    -0x64(%rbp),%eax
cmp    -0x54(%rbp),%eax
jne    11f1 <main+0xe1>
movl   $0x2,-0x4(%rbp)
jmp    123d <main+0x12d>
jmp    11f6 <main+0xe6>
mov    -0x10(%rbp),%rax
mov    %eax,-0x68(%rbp)
mov    -0x68(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x6c(%rbp)
mov    -0x6c(%rbp),%eax
mov    %rax,-0x90(%rbp)
mov    -0x90(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x78(%rbp)
mov    -0x78(%rbp),%rax
mov    %rax,-0x98(%rbp)
mov    -0x98(%rbp),%rax
movl   $0x1,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0x8,%edi
call   1030 <malloc@plt>
mov    %rax,%rbx
test   %ebx,%ebx
je     1140 <main+0x30>
mov    $0x4,%edi
call   1030 <malloc@plt>
add    $0x4,%ebx
mov    %rax,(%rbx)
test   %eax,%eax
je     1147 <main+0x37>
movl   $0x1,(%rax)
xor    %eax,%eax
pop    %rbx
ret
mov    $0x1,%eax
pop    %rbx
ret
mov    $0x2,%eax
pop    %rbx
ret

LLVM IR (-O0):
%struct.str = type { i32 }
%struct.ptr = type { i32 }
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.str*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca %struct.ptr*
%13 = alloca i32
%14 = alloca i8*
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca %struct.ptr*
%19 = alloca %struct.ptr**
%20 = alloca %struct.ptr**
%21 = alloca %struct.ptr**
%22 = alloca i32*
store i32 0, i32* %1
%23 = call i8* @malloc(i32 8)
store i8* %23, i8** %3
%24 = load i8*, i8** %3
%25 = bitcast i8* %24 to %struct.str*
store %struct.str* %25, %struct.str** %2
%26 = load %struct.str*, %struct.str** %2
%27 = ptrtoint %struct.str* %26 to i32
store i32 %27, i32* %5
store i8* null, i8** %6
%28 = load i8*, i8** %6
%29 = ptrtoint i8* %28 to i32
store i32 %29, i32* %7
%30 = load i32, i32* %7
%31 = load i32, i32* %5
%32 = icmp eq i32 %30, %31
br i1 %32, label %33, label %34
33: ; preds = %0
store i32 1, i32* %1
br label %78
34: ; preds = %0
br label %35
35: ; preds = %34
%36 = call i8* @malloc(i32 4)
store i8* %36, i8** %4
%37 = load %struct.str*, %struct.str** %2
%38 = ptrtoint %struct.str* %37 to i32
store i32 %38, i32* %8
%39 = load i32, i32* %8
%40 = add i32 %39, 4
store i32 %40, i32* %9
%41 = load i32, i32* %9
%42 = zext i32 %41 to i64
%43 = inttoptr i64 %42 to %struct.ptr**
store %struct.ptr** %43, %struct.ptr*** %19
%44 = load i8*, i8** %4
%45 = bitcast i8* %44 to %struct.ptr*
%46 = load %struct.ptr**, %struct.ptr*** %19
store %struct.ptr* %45, %struct.ptr** %46
%47 = load %struct.str*, %struct.str** %2
%48 = ptrtoint %struct.str* %47 to i32
store i32 %48, i32* %10
%49 = load i32, i32* %10
%50 = add i32 %49, 4
store i32 %50, i32* %11
%51 = load i32, i32* %11
%52 = zext i32 %51 to i64
%53 = inttoptr i64 %52 to %struct.ptr**
store %struct.ptr** %53, %struct.ptr*** %20
%54 = load %struct.ptr**, %struct.ptr*** %20
%55 = load %struct.ptr*, %struct.ptr** %54
store %struct.ptr* %55, %struct.ptr** %12
%56 = load %struct.ptr*, %struct.ptr** %12
%57 = ptrtoint %struct.ptr* %56 to i32
store i32 %57, i32* %13
store i8* null, i8** %14
%58 = load i8*, i8** %14
%59 = ptrtoint i8* %58 to i32
store i32 %59, i32* %15
%60 = load i32, i32* %15
%61 = load i32, i32* %13
%62 = icmp eq i32 %60, %61
br i1 %62, label %63, label %64
63: ; preds = %35
store i32 2, i32* %1
br label %78
64: ; preds = %35
br label %65
65: ; preds = %64
%66 = load %struct.str*, %struct.str** %2
%67 = ptrtoint %struct.str* %66 to i32
store i32 %67, i32* %16
%68 = load i32, i32* %16
%69 = add i32 %68, 4
store i32 %69, i32* %17
%70 = load i32, i32* %17
%71 = zext i32 %70 to i64
%72 = inttoptr i64 %71 to %struct.ptr**
store %struct.ptr** %72, %struct.ptr*** %21
%73 = load %struct.ptr**, %struct.ptr*** %21
%74 = load %struct.ptr*, %struct.ptr** %73
store %struct.ptr* %74, %struct.ptr** %18
%75 = load %struct.ptr*, %struct.ptr** %18
%76 = bitcast %struct.ptr* %75 to i32*
store i32* %76, i32** %22
%77 = load i32*, i32** %22
store i32 1, i32* %77
store i32 0, i32* %1
br label %78
78: ; preds = %65, %63, %33
%79 = load i32, i32* %1
ret i32 %79
}

LLVM IR (-O2):
%struct.ptr = type { i32 }
define i32 @main() {
%1 = tail call dereferenceable_or_null(8) i8* @malloc(i32 8)
%2 = ptrtoint i8* %1 to i64
%3 = trunc i64 %2 to i32
%4 = icmp eq i32 %3, 0
br i1 %4, label %16, label %5
5: ; preds = %0
%6 = tail call dereferenceable_or_null(4) i8* @malloc(i32 4)
%7 = add i64 %2, 4
%8 = and i64 %7, 4294967295
%9 = inttoptr i64 %8 to i8**
store i8* %6, i8** %9
%10 = ptrtoint i8* %6 to i64
%11 = trunc i64 %10 to i32
%12 = icmp eq i32 %11, 0
br i1 %12, label %16, label %13
13: ; preds = %5
%14 = bitcast i8* %6 to %struct.ptr*
%15 = getelementptr %struct.ptr, %struct.ptr* %14, i64 0, i32 0
store i32 1, i32* %15
br label %16
16: ; preds = %5, %0, %13
%17 = phi i32 [ 0, %13 ], [ 1, %0 ], [ 2, %5 ]
ret i32 %17
}