#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ search_replace_string(char *, char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ strcpy(char *, char *);
char *strdup(char *);
scalar_t__ timlib_exists_string(char *, char *);
void element_push_button_output(FILE *output_file, char *element_label, int row,
                                char *onclick_function) {
  fprintf(output_file, "<input type=\"button\"");
  if (element_label && *element_label) {
    fprintf(output_file, " value=\"%s\"", element_label);
  }
  if (onclick_function) {
    if (timlib_exists_string(onclick_function, "$row")) {
      char buffer[128];
      char row_string[16];
      strcpy(buffer, onclick_function);
      sprintf(row_string, "%d", row);
      search_replace_string(buffer, "$row", row_string);
      onclick_function = strdup(buffer);
    }
    fprintf(output_file, " onclick=\"%s\"", onclick_function);
  }
  fprintf(output_file, ">\n");
}


x86 assembly (clang, -O0):
<element_push_button_output>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe7b(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
cmpq   $0x0,-0x10(%rbp)
je     11bd <element_push_button_output+0x5d>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11bd <element_push_button_output+0x5d>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xe5f(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
cmpq   $0x0,-0x20(%rbp)
je     1248 <element_push_button_output+0xe8>
mov    -0x20(%rbp),%rdi
lea    0xe4e(%rip),%rsi
call   1030 <timlib_exists_string@plt>
cmp    $0x0,%rax
je     1232 <element_push_button_output+0xd2>
lea    -0xa0(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <strcpy@plt>
lea    -0xb0(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0xe23(%rip),%rsi
call   1070 <sprintf@plt>
lea    -0xa0(%rbp),%rdi
lea    -0xb0(%rbp),%rdx
lea    0xe04(%rip),%rsi
call   1050 <search_replace_string@plt>
lea    -0xa0(%rbp),%rdi
call   1080 <strdup@plt>
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xde8(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x8(%rbp),%rdi
lea    0xde4(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<element_push_button_output>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x98,%rsp
mov    %rcx,%rbx
mov    %edx,%r15d
mov    %rsi,%rbp
mov    %rdi,%r14
lea    0xe70(%rip),%rdi
mov    $0x14,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1080 <fwrite@plt>
test   %rbp,%rbp
je     11c1 <element_push_button_output+0x51>
cmpb   $0x0,0x0(%rbp)
je     11c1 <element_push_button_output+0x51>
lea    0xe61(%rip),%rsi
mov    %r14,%rdi
mov    %rbp,%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
test   %rbx,%rbx
je     1230 <element_push_button_output+0xc0>
lea    0xe54(%rip),%rsi
mov    %rbx,%rdi
call   1030 <timlib_exists_string@plt>
test   %rax,%rax
je     121c <element_push_button_output+0xac>
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1040 <strcpy@plt>
lea    0xe35(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %r15d,%edx
call   1070 <sprintf@plt>
lea    0xe1b(%rip),%rsi
mov    %rbp,%rdi
mov    %rbx,%rdx
call   1050 <search_replace_string@plt>
mov    %rbp,%rdi
call   1090 <strdup@plt>
mov    %rax,%rbx
lea    0xe06(%rip),%rsi
mov    %r14,%rdi
mov    %rbx,%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
lea    0xe00(%rip),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1080 <fwrite@plt>
add    $0x98,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [21 x i8] c"<input type=\22button\22\00"
@.str.1 = [12 x i8] c" value=\22%s\22\00"
@.str.2 = [5 x i8] c"$row\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [14 x i8] c" onclick=\22%s\22\00"
@.str.5 = [3 x i8] c">\0A\00"
define void @element_push_button_output(i32* %0, i8* %1, i32 %2, i8* %3) {
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca [128 x i8]
%10 = alloca [16 x i8]
store i32* %0, i32** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i8* %3, i8** %8
%11 = load i32*, i32** %5
%12 = call i32 (i32*, i8*, ...) @fprintf(i32* %11, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%13 = load i8*, i8** %6
%14 = icmp ne i8* %13, null
br i1 %14, label %15, label %24
15: ; preds = %4
%16 = load i8*, i8** %6
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %24
20: ; preds = %15
%21 = load i32*, i32** %5
%22 = load i8*, i8** %6
%23 = call i32 (i32*, i8*, ...) @fprintf(i32* %21, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %22)
br label %24
24: ; preds = %20, %15, %4
%25 = load i8*, i8** %8
%26 = icmp ne i8* %25, null
br i1 %26, label %27, label %47
27: ; preds = %24
%28 = load i8*, i8** %8
%29 = call i64 @timlib_exists_string(i8* %28, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%30 = icmp ne i64 %29, 0
br i1 %30, label %31, label %43
31: ; preds = %27
%32 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 0
%33 = load i8*, i8** %8
%34 = call i32 @strcpy(i8* %32, i8* %33)
%35 = getelementptr inbounds [16 x i8], [16 x i8]* %10, i64 0, i64 0
%36 = load i32, i32* %7
%37 = call i32 @sprintf(i8* %35, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %36)
%38 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 0
%39 = getelementptr inbounds [16 x i8], [16 x i8]* %10, i64 0, i64 0
%40 = call i32 @search_replace_string(i8* %38, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %39)
%41 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 0
%42 = call i8* @strdup(i8* %41)
store i8* %42, i8** %8
br label %43
43: ; preds = %31, %27
%44 = load i32*, i32** %5
%45 = load i8*, i8** %8
%46 = call i32 (i32*, i8*, ...) @fprintf(i32* %44, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i8* %45)
br label %47
47: ; preds = %43, %24
%48 = load i32*, i32** %5
%49 = call i32 (i32*, i8*, ...) @fprintf(i32* %48, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [21 x i8] c"<input type=\22button\22\00"
@.str.1 = [12 x i8] c" value=\22%s\22\00"
@.str.2 = [5 x i8] c"$row\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [14 x i8] c" onclick=\22%s\22\00"
@.str.5 = [3 x i8] c">\0A\00"
define void @element_push_button_output(i32* nocapture %0, i8* %1, i32 %2, i8* %3) {
%5 = alloca [128 x i8]
%6 = alloca [16 x i8]
%7 = tail call i64 @fwrite(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i64 20, i64 1, i32* %0)
%8 = icmp eq i8* %1, null
br i1 %8, label %14, label %9
9: ; preds = %4
%10 = load i8, i8* %1
%11 = icmp eq i8 %10, 0
br i1 %11, label %14, label %12
12: ; preds = %9
%13 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %1)
br label %14
14: ; preds = %12, %9, %4
%15 = icmp eq i8* %3, null
br i1 %15, label %29, label %16
16: ; preds = %14
%17 = tail call i64 @timlib_exists_string(i8* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %26, label %19
19: ; preds = %16
%20 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%21 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 0
%22 = call i32 @strcpy(i8* %20, i8* %3)
%23 = call i32 @sprintf(i8* %21, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %2)
%24 = call i32 @search_replace_string(i8* %20, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %21)
%25 = call i8* @strdup(i8* %20)
br label %26
26: ; preds = %19, %16
%27 = phi i8* [ %25, %19 ], [ %3, %16 ]
%28 = call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i8* %27)
br label %29
29: ; preds = %26, %14
%30 = call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i64 2, i64 1, i32* %0)
ret void
}