#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 /*<<< orphan*/ snprintf(char *, int, char *, char const *);
scalar_t__ strstart(char const *, char *, char const **);
void get_reloc_expr(char *name, int name_size, const char *sym_name) {
  const char *p;
  if (strstart(sym_name, "__op_param", &p)) {
    snprintf(name, name_size, "param%s", p);
  } else if (strstart(sym_name, "__op_gen_label", &p)) {
    snprintf(name, name_size, "gen_labels[param%s]", p);
  } else {
    snprintf(name, name_size, "(long)(&%s)", sym_name);
  }
}


x86 assembly (clang, -O0):
<get_reloc_expr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xec2(%rip),%rsi
lea    -0x20(%rbp),%rdx
call   1030 <strstart@plt>
cmp    $0x0,%rax
je     116d <get_reloc_expr+0x4d>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x20(%rbp),%rcx
lea    0xea8(%rip),%rdx
call   1040 <snprintf@plt>
jmp    11c3 <get_reloc_expr+0xa3>
mov    -0x18(%rbp),%rdi
lea    0xe9b(%rip),%rsi
lea    -0x20(%rbp),%rdx
call   1030 <strstart@plt>
cmp    $0x0,%rax
je     11a7 <get_reloc_expr+0x87>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x20(%rbp),%rcx
lea    0xe85(%rip),%rdx
call   1040 <snprintf@plt>
jmp    11be <get_reloc_expr+0x9e>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x18(%rbp),%rcx
lea    0xe7d(%rip),%rdx
call   1040 <snprintf@plt>
jmp    11c3 <get_reloc_expr+0xa3>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_reloc_expr>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%rbp
mov    %esi,%r14d
mov    %rdi,%rbx
lea    0xec8(%rip),%rsi
lea    0x8(%rsp),%rdx
mov    %rbp,%rdi
call   1030 <strstart@plt>
test   %rax,%rax
je     1158 <get_reloc_expr+0x38>
mov    0x8(%rsp),%rcx
lea    0xeb5(%rip),%rdx
jmp    117d <get_reloc_expr+0x5d>
lea    0xeb4(%rip),%rsi
lea    0x8(%rsp),%rdx
mov    %rbp,%rdi
call   1030 <strstart@plt>
test   %rax,%rax
je     1191 <get_reloc_expr+0x71>
mov    0x8(%rsp),%rcx
lea    0xea5(%rip),%rdx
mov    %rbx,%rdi
mov    %r14d,%esi
call   1040 <snprintf@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xe9e(%rip),%rdx
mov    %rbx,%rdi
mov    %r14d,%esi
mov    %rbp,%rcx
jmp    1183 <get_reloc_expr+0x63>

LLVM IR (-O0):
@.str = [11 x i8] c"__op_param\00"
@.str.1 = [8 x i8] c"param%s\00"
@.str.2 = [15 x i8] c"__op_gen_label\00"
@.str.3 = [20 x i8] c"gen_labels[param%s]\00"
@.str.4 = [12 x i8] c"(long)(&%s)\00"
define void @get_reloc_expr(i8* %0, i32 %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
store i8* %0, i8** %4
store i32 %1, i32* %5
store i8* %2, i8** %6
%8 = load i8*, i8** %6
%9 = call i64 @strstart(i8* %8, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8** %7)
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %16
11: ; preds = %3
%12 = load i8*, i8** %4
%13 = load i32, i32* %5
%14 = load i8*, i8** %7
%15 = call i32 @snprintf(i8* %12, i32 %13, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %14)
br label %31
16: ; preds = %3
%17 = load i8*, i8** %6
%18 = call i64 @strstart(i8* %17, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8** %7)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %25
20: ; preds = %16
%21 = load i8*, i8** %4
%22 = load i32, i32* %5
%23 = load i8*, i8** %7
%24 = call i32 @snprintf(i8* %21, i32 %22, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i8* %23)
br label %30
25: ; preds = %16
%26 = load i8*, i8** %4
%27 = load i32, i32* %5
%28 = load i8*, i8** %6
%29 = call i32 @snprintf(i8* %26, i32 %27, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i8* %28)
br label %30
30: ; preds = %25, %20
br label %31
31: ; preds = %30, %11
ret void
}

LLVM IR (-O2):
@.str = [11 x i8] c"__op_param\00"
@.str.1 = [8 x i8] c"param%s\00"
@.str.2 = [15 x i8] c"__op_gen_label\00"
@.str.3 = [20 x i8] c"gen_labels[param%s]\00"
@.str.4 = [12 x i8] c"(long)(&%s)\00"
define void @get_reloc_expr(i8* %0, i32 %1, i8* %2) {
%4 = alloca i8*
%5 = bitcast i8** %4 to i8*
%6 = call i64 @strstart(i8* %2, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8** %4)
%7 = icmp eq i64 %6, 0
br i1 %7, label %11, label %8
8: ; preds = %3
%9 = load i8*, i8** %4
%10 = call i32 @snprintf(i8* %0, i32 %1, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %9)
br label %19
11: ; preds = %3
%12 = call i64 @strstart(i8* %2, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8** %4)
%13 = icmp eq i64 %12, 0
br i1 %13, label %17, label %14
14: ; preds = %11
%15 = load i8*, i8** %4
%16 = call i32 @snprintf(i8* %0, i32 %1, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i8* %15)
br label %19
17: ; preds = %11
%18 = call i32 @snprintf(i8* %0, i32 %1, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i8* %2)
br label %19
19: ; preds = %14, %17, %8
ret void
}