#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*/ sprintf(char *, char *, int, int);
int /*<<< orphan*/ strcpy(char *, char *);
char *get_version(unsigned char z) {
  int x, y;
  static char vers[10];
  if (z > 15) {
    x = z / 10;
    y = z % 10;
    sprintf(vers, "2.%d.%d", x, y);
  } else {
    strcpy(vers, "unknown");
  }
  return vers;
}


x86 assembly (clang, -O0):
<get_version>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movzbl -0x1(%rbp),%eax
cmp    $0xf,%eax
jle    1177 <get_version+0x57>
movzbl -0x1(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
movzbl -0x1(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
mov    -0x8(%rbp),%edx
mov    -0xc(%rbp),%ecx
lea    0x2ecb(%rip),%rdi
lea    0xe93(%rip),%rsi
call   1040 <sprintf@plt>
jmp    118a <get_version+0x6a>
lea    0x2eb3(%rip),%rdi
lea    0xe83(%rip),%rsi
call   1030 <strcpy@plt>
lea    0x2ea0(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_version>:
push   %rax
cmp    $0x10,%dil
jb     1156 <get_version+0x36>
movzbl %dil,%eax
imul   $0xcd,%eax,%edx
shr    $0xb,%edx
lea    (%rdx,%rdx,1),%eax
lea    (%rax,%rax,4),%eax
sub    %al,%dil
movzbl %dil,%ecx
lea    0x2ee9(%rip),%rdi
lea    0xeb1(%rip),%rsi
call   1040 <sprintf@plt>
jmp    1169 <get_version+0x49>
lea    0x2ed4(%rip),%rdi
lea    0xea4(%rip),%rsi
call   1030 <strcpy@plt>
lea    0x2ec1(%rip),%rax
pop    %rcx
ret

LLVM IR (-O0):
@get_version.vers = internal global [10 x i8] zeroinitializer
@.str = [8 x i8] c"2.%d.%d\00"
@.str.1 = [8 x i8] c"unknown\00"
define i8* @get_version(i8 zeroext %0) {
%2 = alloca i8
%3 = alloca i32
%4 = alloca i32
store i8 %0, i8* %2
%5 = load i8, i8* %2
%6 = zext i8 %5 to i32
%7 = icmp sgt i32 %6, 15
br i1 %7, label %8, label %18
8: ; preds = %1
%9 = load i8, i8* %2
%10 = zext i8 %9 to i32
%11 = sdiv i32 %10, 10
store i32 %11, i32* %3
%12 = load i8, i8* %2
%13 = zext i8 %12 to i32
%14 = srem i32 %13, 10
store i32 %14, i32* %4
%15 = load i32, i32* %3
%16 = load i32, i32* %4
%17 = call i32 @sprintf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @get_version.vers, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %15, i32 %16)
br label %20
18: ; preds = %1
%19 = call i32 @strcpy(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @get_version.vers, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
br label %20
20: ; preds = %18, %8
ret i8* getelementptr inbounds ([10 x i8], [10 x i8]* @get_version.vers, i64 0, i64 0)
}

LLVM IR (-O2):
@get_version.vers = internal global [10 x i8] zeroinitializer
@.str = [8 x i8] c"2.%d.%d\00"
@.str.1 = [8 x i8] c"unknown\00"
define i8* @get_version(i8 zeroext %0) {
%2 = icmp ugt i8 %0, 15
br i1 %2, label %3, label %9
3: ; preds = %1
%4 = udiv i8 %0, 10
%5 = zext i8 %4 to i32
%6 = urem i8 %0, 10
%7 = zext i8 %6 to i32
%8 = tail call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @get_version.vers, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %5, i32 %7)
br label %11
9: ; preds = %1
%10 = tail call i32 @strcpy(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @get_version.vers, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
br label %11
11: ; preds = %9, %3
ret i8* getelementptr inbounds ([10 x i8], [10 x i8]* @get_version.vers, i64 0, i64 0)
}