#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*/ printf(char *, char *, int, int, char *);
char *rindex(char *, char);
void version(char *prog, int version, char *date) {
  char *ptr;
  ptr = rindex(prog, '/');
  if (!ptr)
    ptr = prog;
  else
    ptr++;
  printf("\n%s %d.%02d (%s)\n", ptr, version / 100, version % 100, date);
}


x86 assembly (clang, -O0):
<version>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x2f,%esi
call   1040 <rindex@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    115d <version+0x3d>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
jmp    1169 <version+0x49>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
mov    -0xc(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %eax,-0x24(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %edx,%ecx
mov    -0x24(%rbp),%edx
mov    -0x18(%rbp),%r8
lea    0xe6a(%rip),%rdi
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<version>:
push   %rbp
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %esi,%ebp
mov    %rdi,%rbx
mov    $0x2f,%esi
call   1040 <rindex@plt>
lea    0x1(%rax),%rsi
test   %rax,%rax
cmove  %rbx,%rsi
movslq %ebp,%rcx
imul   $0x51eb851f,%rcx,%rdx
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x25,%rdx
add    %eax,%edx
imul   $0x64,%edx,%eax
sub    %eax,%ecx
lea    0xe9c(%rip),%rdi
mov    %r14,%r8
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [18 x i8] c"\0A%s %d.%02d (%s)\0A\00"
define void @version(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** %4
%9 = call i8* @rindex(i8* %8, i8 signext 47)
store i8* %9, i8** %7
%10 = load i8*, i8** %7
%11 = icmp ne i8* %10, null
br i1 %11, label %14, label %12
12: ; preds = %3
%13 = load i8*, i8** %4
store i8* %13, i8** %7
br label %17
14: ; preds = %3
%15 = load i8*, i8** %7
%16 = getelementptr inbounds i8, i8* %15, i32 1
store i8* %16, i8** %7
br label %17
17: ; preds = %14, %12
%18 = load i8*, i8** %7
%19 = load i32, i32* %5
%20 = sdiv i32 %19, 100
%21 = load i32, i32* %5
%22 = srem i32 %21, 100
%23 = load i8*, i8** %6
%24 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %18, i32 %20, i32 %22, i8* %23)
ret void
}

LLVM IR (-O2):
@.str = [18 x i8] c"\0A%s %d.%02d (%s)\0A\00"
define void @version(i8* %0, i32 %1, i8* %2) {
%4 = tail call i8* @rindex(i8* %0, i8 signext 47)
%5 = icmp eq i8* %4, null
%6 = getelementptr inbounds i8, i8* %4, i64 1
%7 = select i1 %5, i8* %0, i8* %6
%8 = sdiv i32 %1, 100
%9 = srem i32 %1, 100
%10 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %7, i32 %8, i32 %9, i8* %2)
ret void
}