#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 */
char *basename(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char const *,
                           int /*<<< orphan*/, int, int /*<<< orphan*/, char *);
void version(FILE *fp, const char *prog) {
  const char *bn;
  if (!prog)
    prog = "search";
  bn = basename((char *)((char *)prog));
  if (!bn || !(*bn))
    bn = prog;
  fprintf(fp,
          "%s version %d.%d.%d, built "
          "Mar 18 2022"
          " "
          "08:34:30"
          "\n"
          "%s\n",
          bn, 0, 1, 0, "Copyright (c) 2005, mtbaldy.us\nAll Rights Reserved");
}


x86 assembly (clang, -O0):
<version>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1146 <version+0x26>
lea    0xebe(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <basename@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     116b <version+0x4b>
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
jne    1173 <version+0x53>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xe85(%rip),%rsi
xor    %r9d,%r9d
mov    $0x1,%r8d
lea    0xea9(%rip),%rax
mov    %r9d,%ecx
mov    %rax,(%rsp)
call   1030 <fprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<version>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
test   %rsi,%rsi
lea    0xecf(%rip),%rbx
cmovne %rsi,%rbx
mov    %rbx,%rdi
call   1040 <basename@plt>
test   %rax,%rax
je     1147 <version+0x27>
cmpb   $0x0,(%rax)
jne    114a <version+0x2a>
mov    %rbx,%rax
lea    0xeea(%rip),%rcx
mov    %rcx,(%rsp)
lea    0xeab(%rip),%rsi
mov    %r14,%rdi
mov    %rax,%rdx
xor    %ecx,%ecx
mov    $0x1,%r8d
xor    %r9d,%r9d
call   1030 <fprintf@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [7 x i8] c"search\00"
@.str.1 = [52 x i8] c"%s version %d.%d.%d, built Mar 18 2022 08:34:30\0A%s\0A\00"
@.str.2 = [51 x i8] c"Copyright (c) 2005, mtbaldy.us\0AAll Rights Reserved\00"
define void @version(i32* %0, i8* %1) {
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i8*
store i32* %0, i32** %3
store i8* %1, i8** %4
%6 = load i8*, i8** %4
%7 = icmp ne i8* %6, null
br i1 %7, label %9, label %8
8: ; preds = %2
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8** %4
br label %9
9: ; preds = %8, %2
%10 = load i8*, i8** %4
%11 = call i8* @basename(i8* %10)
store i8* %11, i8** %5
%12 = load i8*, i8** %5
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %18
14: ; preds = %9
%15 = load i8*, i8** %5
%16 = load i8, i8* %15
%17 = icmp ne i8 %16, 0
br i1 %17, label %20, label %18
18: ; preds = %14, %9
%19 = load i8*, i8** %4
store i8* %19, i8** %5
br label %20
20: ; preds = %18, %14
%21 = load i32*, i32** %3
%22 = load i8*, i8** %5
%23 = call i32 @fprintf(i32* %21, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.1, i64 0, i64 0), i8* %22, i32 0, i32 1, i32 0, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"search\00"
@.str.1 = [52 x i8] c"%s version %d.%d.%d, built Mar 18 2022 08:34:30\0A%s\0A\00"
@.str.2 = [51 x i8] c"Copyright (c) 2005, mtbaldy.us\0AAll Rights Reserved\00"
define void @version(i32* nocapture %0, i8* %1) {
%3 = icmp eq i8* %1, null
%4 = select i1 %3, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %1
%5 = tail call i8* @basename(i8* %4)
%6 = icmp eq i8* %5, null
br i1 %6, label %10, label %7
7: ; preds = %2
%8 = load i8, i8* %5
%9 = icmp eq i8 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %7, %2
br label %11
11: ; preds = %10, %7
%12 = phi i8* [ %5, %7 ], [ %4, %10 ]
%13 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.1, i64 0, i64 0), i8* %12, i32 0, i32 1, i32 0, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.2, i64 0, i64 0))
ret void
}