#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 */
unsigned long long ULLONG_MAX;
scalar_t__ errno;
scalar_t__ strncmp(char *, char *, int);
unsigned long long strtoull(char *, char **, int);
void *sr_triggerpointer_of(char *name) {
  if (strncmp(name, "pointer:", 8) != 0)
    return NULL;
  name += 8;
  errno = 0;
  char *end;
  unsigned long long int pointer = strtoull(name, &end, 16);
  if (pointer == 0 && end == name) {
    return NULL;
  } else if (pointer == ULLONG_MAX && errno) {
    return NULL;
  }
  return (void *)(uintptr_t)pointer;
}


x86 assembly (clang, -O0):
<sr_triggerpointer_of>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xec9(%rip),%rsi
mov    $0x8,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     1158 <sr_triggerpointer_of+0x38>
movq   $0x0,-0x8(%rbp)
jmp    11ed <sr_triggerpointer_of+0xcd>
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
mov    0x2e6d(%rip),%rax
movq   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x10,%edx
call   1040 <strtoull@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11ae <sr_triggerpointer_of+0x8e>
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jne    11ae <sr_triggerpointer_of+0x8e>
movq   $0x0,-0x8(%rbp)
jmp    11ed <sr_triggerpointer_of+0xcd>
mov    -0x20(%rbp),%rax
mov    0x2e2f(%rip),%rcx
cmp    (%rcx),%rax
jne    11e0 <sr_triggerpointer_of+0xc0>
mov    0x2e0f(%rip),%rax
cmpq   $0x0,(%rax)
je     11e0 <sr_triggerpointer_of+0xc0>
movq   $0x0,-0x8(%rbp)
jmp    11ed <sr_triggerpointer_of+0xcd>
jmp    11e5 <sr_triggerpointer_of+0xc5>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sr_triggerpointer_of>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xed2(%rip),%rsi
mov    $0x8,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    116d <sr_triggerpointer_of+0x4d>
add    $0x8,%rbx
mov    0x2e90(%rip),%r14
movq   $0x0,(%r14)
mov    %rsp,%rsi
mov    %rbx,%rdi
mov    $0x10,%edx
call   1040 <strtoull@plt>
mov    %rax,%rcx
test   %rax,%rax
jne    1171 <sr_triggerpointer_of+0x51>
cmp    %rbx,(%rsp)
jne    1171 <sr_triggerpointer_of+0x51>
xor    %eax,%eax
jmp    1189 <sr_triggerpointer_of+0x69>
mov    0x2e70(%rip),%rdx
xor    %eax,%eax
cmpq   $0x0,(%r14)
cmove  %rcx,%rax
cmp    (%rdx),%rcx
cmovne %rcx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [9 x i8] c"pointer:\00"
@errno = global i64 0
@ULLONG_MAX = global i64 0
define i8* @sr_triggerpointer_of(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i64
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = call i64 @strncmp(i8* %6, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 8)
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %1
store i8* null, i8** %2
br label %34
10: ; preds = %1
%11 = load i8*, i8** %3
%12 = getelementptr inbounds i8, i8* %11, i64 8
store i8* %12, i8** %3
store i64 0, i64* @errno
%13 = load i8*, i8** %3
%14 = call i64 @strtoull(i8* %13, i8** %4, i32 16)
store i64 %14, i64* %5
%15 = load i64, i64* %5
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %22
17: ; preds = %10
%18 = load i8*, i8** %4
%19 = load i8*, i8** %3
%20 = icmp eq i8* %18, %19
br i1 %20, label %21, label %22
21: ; preds = %17
store i8* null, i8** %2
br label %34
22: ; preds = %17, %10
%23 = load i64, i64* %5
%24 = load i64, i64* @ULLONG_MAX
%25 = icmp eq i64 %23, %24
br i1 %25, label %26, label %30
26: ; preds = %22
%27 = load i64, i64* @errno
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %30
29: ; preds = %26
store i8* null, i8** %2
br label %34
30: ; preds = %26, %22
br label %31
31: ; preds = %30
%32 = load i64, i64* %5
%33 = inttoptr i64 %32 to i8*
store i8* %33, i8** %2
br label %34
34: ; preds = %31, %29, %21, %9
%35 = load i8*, i8** %2
ret i8* %35
}

LLVM IR (-O2):
@.str = [9 x i8] c"pointer:\00"
@errno = global i64 0
@ULLONG_MAX = global i64 0
define i8* @sr_triggerpointer_of(i8* %0) {
%2 = alloca i8*
%3 = tail call i64 @strncmp(i8* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 8)
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %23
5: ; preds = %1
%6 = getelementptr inbounds i8, i8* %0, i64 8
store i64 0, i64* @errno
%7 = bitcast i8** %2 to i8*
%8 = call i64 @strtoull(i8* %6, i8** %2, i32 16)
%9 = icmp eq i64 %8, 0
%10 = load i8*, i8** %2
%11 = icmp eq i8* %10, %6
%12 = select i1 %9, i1 %11, i1 false
br i1 %12, label %21, label %13
13: ; preds = %5
%14 = load i64, i64* @ULLONG_MAX
%15 = icmp eq i64 %8, %14
%16 = load i64, i64* @errno
%17 = icmp ne i64 %16, 0
%18 = select i1 %15, i1 %17, i1 false
%19 = inttoptr i64 %8 to i8*
%20 = select i1 %18, i8* null, i8* %19
br label %21
21: ; preds = %13, %5
%22 = phi i8* [ null, %5 ], [ %20, %13 ]
br label %23
23: ; preds = %1, %21
%24 = phi i8* [ %22, %21 ], [ null, %1 ]
ret i8* %24
}