void pp_math(int **x) {
  printf("%s: x = %p\n", __func__, x);
  printf("%s: *x = %p\n", __func__, *x);
  if (*x == 0) {
    printf("Allocation 1 pointer\n");
    *x = (int *)malloc(sizeof(int));
    printf("%s: *x = %p [malloc]\n", __func__, *x);
    if (*x != 0) {
      **x = 0;
      do_math(*x);
      free(*x);
    }
  }
}


x86 assembly (clang, -O0):
<pp_math>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdx
lea    0xea9(%rip),%rdi
lea    0xeae(%rip),%rsi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdx
lea    0xea1(%rip),%rdi
lea    0xe92(%rip),%rsi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x8(%rbp),%rax
cmpq   $0x0,(%rax)
jne    1207 <pp_math+0xc7>
lea    0xe8b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x4,%edi
call   1060 <malloc@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%rdx
lea    0xe78(%rip),%rdi
lea    0xe46(%rip),%rsi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x8(%rbp),%rax
cmpq   $0x0,(%rax)
je     1202 <pp_math+0xc2>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movl   $0x0,(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
mov    $0x0,%al
call   1040 <do_math@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
call   1030 <free@plt>
jmp    1207 <pp_math+0xc7>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pp_math>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xea2(%rip),%rdi
lea    0xea7(%rip),%r14
mov    %r14,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1060 <printf@plt>
mov    (%rbx),%rdx
lea    0xe98(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
cmpq   $0x0,(%rbx)
je     1194 <pp_math+0x44>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe9c(%rip),%rdi
call   1040 <puts@plt>
mov    $0x4,%edi
call   1070 <malloc@plt>
mov    %rax,(%rbx)
lea    0xe6d(%rip),%rdi
lea    0xe51(%rip),%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1060 <printf@plt>
mov    (%rbx),%rdi
test   %rdi,%rdi
je     118c <pp_math+0x3c>
movl   $0x0,(%rdi)
xor    %eax,%eax
call   1050 <do_math@plt>
mov    (%rbx),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <free@plt>

LLVM IR (-O0):
@.str = [12 x i8] c"%s: x = %p\0A\00"
@__func__.pp_math = [8 x i8] c"pp_math\00"
@.str.1 = [13 x i8] c"%s: *x = %p\0A\00"
@.str.2 = [22 x i8] c"Allocation 1 pointer\0A\00"
@.str.3 = [22 x i8] c"%s: *x = %p [malloc]\0A\00"
define void @pp_math(i32** %0) {
%2 = alloca i32**
store i32** %0, i32*** %2
%3 = load i32**, i32*** %2
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @__func__.pp_math, i64 0, i64 0), i32** %3)
%5 = load i32**, i32*** %2
%6 = load i32*, i32** %5
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @__func__.pp_math, i64 0, i64 0), i32* %6)
%8 = load i32**, i32*** %2
%9 = load i32*, i32** %8
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %32
11: ; preds = %1
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%13 = call i8* @malloc(i64 4)
%14 = bitcast i8* %13 to i32*
%15 = load i32**, i32*** %2
store i32* %14, i32** %15
%16 = load i32**, i32*** %2
%17 = load i32*, i32** %16
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @__func__.pp_math, i64 0, i64 0), i32* %17)
%19 = load i32**, i32*** %2
%20 = load i32*, i32** %19
%21 = icmp ne i32* %20, null
br i1 %21, label %22, label %31
22: ; preds = %11
%23 = load i32**, i32*** %2
%24 = load i32*, i32** %23
store i32 0, i32* %24
%25 = load i32**, i32*** %2
%26 = load i32*, i32** %25
%27 = call i32 (i32*, ...) bitcast (i32 (...)* @do_math to i32 (i32*, ...)*)(i32* %26)
%28 = load i32**, i32*** %2
%29 = load i32*, i32** %28
%30 = bitcast i32* %29 to i8*
br label %31
31: ; preds = %22, %11
br label %32
32: ; preds = %31, %1
ret void
}

LLVM IR (-O2):
@.str = [12 x i8] c"%s: x = %p\0A\00"
@__func__.pp_math = [8 x i8] c"pp_math\00"
@.str.1 = [13 x i8] c"%s: *x = %p\0A\00"
@.str.3 = [22 x i8] c"%s: *x = %p [malloc]\0A\00"
@str = [21 x i8] c"Allocation 1 pointer\00"
define void @pp_math(i32** %0) {
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @__func__.pp_math, i64 0, i64 0), i32** %0)
%3 = load i32*, i32** %0
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @__func__.pp_math, i64 0, i64 0), i32* %3)
%5 = load i32*, i32** %0
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %17
7: ; preds = %1
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
%9 = tail call dereferenceable_or_null(4) i8* @malloc(i64 4)
%10 = bitcast i32** %0 to i8**
store i8* %9, i8** %10
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @__func__.pp_math, i64 0, i64 0), i8* %9)
%12 = load i32*, i32** %0
%13 = icmp eq i32* %12, null
br i1 %13, label %17, label %14
14: ; preds = %7
store i32 0, i32* %12
%15 = tail call i32 (i32*, ...) bitcast (i32 (...)* @do_math to i32 (i32*, ...)*)(i32* %12)
%16 = load i8*, i8** %10
tail call void @free(i8* %16)
br label %17
17: ; preds = %7, %14, %1
ret void
}