void do_cmath(char *x) {
  printf("%s: X = %p\n", __func__, x);
  if (x) {
    printf("%s: X before: %d\n", __func__, *x);
    *x += 5;
    printf("%s: X after: %d\n", __func__, *x);
  } else
    printf("%s: Invalid pointer to do math!\n", __func__);
}


x86 assembly (clang, -O0):
<do_cmath>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdx
lea    0xed9(%rip),%rdi
lea    0xede(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
cmpq   $0x0,-0x8(%rbp)
je     1189 <do_cmath+0x79>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edx
lea    0xec7(%rip),%rdi
lea    0xeb7(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
movsbl (%rax),%ecx
add    $0x5,%ecx
mov    %cl,(%rax)
mov    -0x8(%rbp),%rax
movsbl (%rax),%edx
lea    0xeb1(%rip),%rdi
lea    0xe8f(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    119e <do_cmath+0x8e>
lea    0xea8(%rip),%rdi
lea    0xe75(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_cmath>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xee2(%rip),%rdi
lea    0xee7(%rip),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1030 <printf@plt>
test   %rbx,%rbx
je     1170 <do_cmath+0x60>
movsbl (%rbx),%edx
lea    0xed7(%rip),%rdi
lea    0xec7(%rip),%r14
mov    %r14,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    (%rbx),%al
add    $0x5,%al
mov    %al,(%rbx)
movsbl %al,%edx
lea    0xec8(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <printf@plt>
lea    0xec1(%rip),%rdi
lea    0xe8e(%rip),%rsi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [12 x i8] c"%s: X = %p\0A\00"
@__func__.do_cmath = [9 x i8] c"do_cmath\00"
@.str.1 = [18 x i8] c"%s: X before: %d\0A\00"
@.str.2 = [17 x i8] c"%s: X after: %d\0A\00"
@.str.3 = [33 x i8] c"%s: Invalid pointer to do math!\0A\00"
define void @do_cmath(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @__func__.do_cmath, i64 0, i64 0), i8* %3)
%5 = load i8*, i8** %2
%6 = icmp ne i8* %5, null
br i1 %6, label %7, label %21
7: ; preds = %1
%8 = load i8*, i8** %2
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @__func__.do_cmath, i64 0, i64 0), i32 %10)
%12 = load i8*, i8** %2
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = add nsw i32 %14, 5
%16 = trunc i32 %15 to i8
store i8 %16, i8* %12
%17 = load i8*, i8** %2
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @__func__.do_cmath, i64 0, i64 0), i32 %19)
br label %23
21: ; preds = %1
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @__func__.do_cmath, i64 0, i64 0))
br label %23
23: ; preds = %21, %7
ret void
}

LLVM IR (-O2):
@.str = [12 x i8] c"%s: X = %p\0A\00"
@__func__.do_cmath = [9 x i8] c"do_cmath\00"
@.str.1 = [18 x i8] c"%s: X before: %d\0A\00"
@.str.2 = [17 x i8] c"%s: X after: %d\0A\00"
@.str.3 = [33 x i8] c"%s: Invalid pointer to do math!\0A\00"
define void @do_cmath(i8* %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 ([9 x i8], [9 x i8]* @__func__.do_cmath, i64 0, i64 0), i8* %0)
%3 = icmp eq i8* %0, null
br i1 %3, label %12, label %4
4: ; preds = %1
%5 = load i8, i8* %0
%6 = sext i8 %5 to i32
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @__func__.do_cmath, i64 0, i64 0), i32 %6)
%8 = load i8, i8* %0
%9 = add i8 %8, 5
store i8 %9, i8* %0
%10 = sext i8 %9 to i32
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @__func__.do_cmath, i64 0, i64 0), i32 %10)
br label %14
12: ; preds = %1
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @__func__.do_cmath, i64 0, i64 0))
br label %14
14: ; preds = %12, %4
ret void
}