#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) {
    bn = basename((char *)((char *)prog));
    if (!bn)
      bn = prog;
  } else
    bn = "search";
  fprintf(fp,
          "%s version %d.%d.%d, built "
          "Mar 18 2022"
          " "
          "08:35:37"
          "\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)
je     1160 <version+0x40>
mov    -0x10(%rbp),%rdi
call   1040 <basename@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    115b <version+0x3b>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
jmp    116b <version+0x4b>
lea    0xe99(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xe8d(%rip),%rsi
xor    %r9d,%r9d
mov    $0x1,%r8d
lea    0xeb1(%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
je     1143 <version+0x23>
mov    %rsi,%rbx
mov    %rsi,%rdi
call   1040 <basename@plt>
mov    %rax,%rdx
test   %rax,%rax
cmove  %rbx,%rdx
jmp    114a <version+0x2a>
lea    0xeb6(%rip),%rdx
lea    0xeea(%rip),%rax
mov    %rax,(%rsp)
lea    0xeab(%rip),%rsi
mov    %r14,%rdi
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:35:37\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 %8, label %16
8: ; preds = %2
%9 = load i8*, i8** %4
%10 = call i8* @basename(i8* %9)
store i8* %10, i8** %5
%11 = load i8*, i8** %5
%12 = icmp ne i8* %11, null
br i1 %12, label %15, label %13
13: ; preds = %8
%14 = load i8*, i8** %4
store i8* %14, i8** %5
br label %15
15: ; preds = %13, %8
br label %17
16: ; preds = %2
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8** %5
br label %17
17: ; preds = %16, %15
%18 = load i32*, i32** %3
%19 = load i8*, i8** %5
%20 = call i32 @fprintf(i32* %18, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.1, i64 0, i64 0), i8* %19, 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:35:37\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
br i1 %3, label %8, label %4
4: ; preds = %2
%5 = tail call i8* @basename(i8* %1)
%6 = icmp eq i8* %5, null
%7 = select i1 %6, i8* %1, i8* %5
br label %8
8: ; preds = %4, %2
%9 = phi i8* [ %7, %4 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), %2 ]
%10 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.1, i64 0, i64 0), i8* %9, i32 0, i32 1, i32 0, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.2, i64 0, i64 0))
ret void
}