#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*/ fprintf(int /*<<< orphan*/, char *, int, char *);
int is_version(char *);
int /*<<< orphan*/ stderr;
int test_version(void) {
  char **test;
  int i, ret;
  char *input[] = {"1,0",  "1.0",   "2.0",   "0.0", "00.0",
                   "10.0", "10.01", "10.10", NULL};
  int result[] = {0, 1, 1, 1, 0, 1, 0, 1};
  test = input;
  i = 0;
  ret = 1;
  while ((*test) != NULL) {
    if (is_version(*test) != result[i]) {
      fprintf(stderr, "test_version(): test %d failed with test=\"%s\"\n", i,
              *test);
      ret = 0;
    }
    test++;
    i++;
  }
  return ret;
}


x86 assembly (clang, -O0):
<test_version>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
lea    -0x60(%rbp),%rdi
lea    0x2c8a(%rip),%rsi
mov    $0x48,%edx
call   1040 <memcpy@plt>
mov    0xf09(%rip),%rax
mov    %rax,-0x80(%rbp)
mov    0xf06(%rip),%rax
mov    %rax,-0x78(%rbp)
mov    0xf03(%rip),%rax
mov    %rax,-0x70(%rbp)
mov    0xf00(%rip),%rax
mov    %rax,-0x68(%rbp)
lea    -0x60(%rbp),%rax
mov    %rax,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
mov    -0x8(%rbp),%rax
cmpq   $0x0,(%rax)
je     11fa <test_version+0xca>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
call   1050 <is_version@plt>
movslq -0xc(%rbp),%rcx
cmp    -0x80(%rbp,%rcx,4),%eax
je     11e0 <test_version+0xb0>
mov    0x2e1f(%rip),%rax
mov    (%rax),%edi
mov    -0xc(%rbp),%edx
mov    -0x8(%rbp),%rax
mov    (%rax),%rcx
lea    0xe4e(%rip),%rsi
call   1030 <fprintf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1192 <test_version+0x62>
mov    -0x10(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_version>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x50,%rsp
mov    0x2cdd(%rip),%rax
mov    %rax,0x40(%rsp)
movaps 0x2cc1(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0x2ca5(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0x2c89(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0x2c6d(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    $0x1,%r15d
lea    0xe8c(%rip),%rdi
lea    0xee5(%rip),%rbp
xor    %ebx,%ebx
mov    0x2e5c(%rip),%r12
lea    0xe97(%rip),%r14
jmp    11a2 <test_version+0x82>
nopl   (%rax)
mov    0x8(%rsp,%rbx,8),%rdi
add    $0x1,%rbx
add    $0x4,%rbp
test   %rdi,%rdi
je     11c3 <test_version+0xa3>
call   1040 <is_version@plt>
cmp    0x0(%rbp),%eax
je     1190 <test_version+0x70>
mov    (%r12),%edi
mov    (%rsp,%rbx,8),%rcx
mov    %r14,%rsi
mov    %ebx,%edx
call   1030 <fprintf@plt>
xor    %r15d,%r15d
jmp    1190 <test_version+0x70>
mov    %r15d,%eax
add    $0x50,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"1,0\00"
@.str.1 = [4 x i8] c"1.0\00"
@.str.2 = [4 x i8] c"2.0\00"
@.str.3 = [4 x i8] c"0.0\00"
@.str.4 = [5 x i8] c"00.0\00"
@.str.5 = [5 x i8] c"10.0\00"
@.str.6 = [6 x i8] c"10.01\00"
@.str.7 = [6 x i8] c"10.10\00"
@__const.test_version.input = [9 x i8*] [i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i32 0, i32 0), i8* null]
@__const.test_version.result = [8 x i32] [i32 0, i32 1, i32 1, i32 1, i32 0, i32 1, i32 0, i32 1]
@stderr = global i32 0
@.str.8 = [47 x i8] c"test_version(): test %d failed with test=\22%s\22\0A\00"
define i32 @test_version() {
%1 = alloca i8**
%2 = alloca i32
%3 = alloca i32
%4 = alloca [9 x i8*]
%5 = alloca [8 x i32]
%6 = bitcast [9 x i8*]* %4 to i8*
%7 = bitcast [8 x i32]* %5 to i8*
%8 = getelementptr inbounds [9 x i8*], [9 x i8*]* %4, i64 0, i64 0
store i8** %8, i8*** %1
store i32 0, i32* %2
store i32 1, i32* %3
br label %9
9: ; preds = %28, %0
%10 = load i8**, i8*** %1
%11 = load i8*, i8** %10
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %33
13: ; preds = %9
%14 = load i8**, i8*** %1
%15 = load i8*, i8** %14
%16 = call i32 @is_version(i8* %15)
%17 = load i32, i32* %2
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [8 x i32], [8 x i32]* %5, i64 0, i64 %18
%20 = load i32, i32* %19
%21 = icmp ne i32 %16, %20
br i1 %21, label %22, label %28
22: ; preds = %13
%23 = load i32, i32* @stderr
%24 = load i32, i32* %2
%25 = load i8**, i8*** %1
%26 = load i8*, i8** %25
%27 = call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.8, i64 0, i64 0), i32 %24, i8* %26)
store i32 0, i32* %3
br label %28
28: ; preds = %22, %13
%29 = load i8**, i8*** %1
%30 = getelementptr inbounds i8*, i8** %29, i32 1
store i8** %30, i8*** %1
%31 = load i32, i32* %2
%32 = add nsw i32 %31, 1
store i32 %32, i32* %2
br label %9
33: ; preds = %9
%34 = load i32, i32* %3
ret i32 %34
}

LLVM IR (-O2):
@.str = [4 x i8] c"1,0\00"
@.str.1 = [4 x i8] c"1.0\00"
@.str.2 = [4 x i8] c"2.0\00"
@.str.3 = [4 x i8] c"0.0\00"
@.str.4 = [5 x i8] c"00.0\00"
@.str.5 = [5 x i8] c"10.0\00"
@.str.6 = [6 x i8] c"10.01\00"
@.str.7 = [6 x i8] c"10.10\00"
@__const.test_version.input = [9 x i8*] [i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i32 0, i32 0), i8* null]
@__const.test_version.result = [8 x i32] [i32 0, i32 1, i32 1, i32 1, i32 0, i32 1, i32 0, i32 1]
@stderr = global i32 0
@.str.8 = [47 x i8] c"test_version(): test %d failed with test=\22%s\22\0A\00"
define i32 @test_version() {
%1 = alloca [9 x i8*]
%2 = bitcast [9 x i8*]* %1 to i8*
%3 = getelementptr inbounds [9 x i8*], [9 x i8*]* %1, i64 0, i64 0
br label %4
4: ; preds = %0, %18
%5 = phi i64 [ 0, %0 ], [ %21, %18 ]
%6 = phi i8* [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), %0 ], [ %22, %18 ]
%7 = phi i32 [ 1, %0 ], [ %19, %18 ]
%8 = phi i8** [ %3, %0 ], [ %20, %18 ]
%9 = tail call i32 @is_version(i8* %6)
%10 = getelementptr inbounds [8 x i32], [8 x i32]* @__const.test_version.result, i64 0, i64 %5
%11 = load i32, i32* %10
%12 = icmp eq i32 %9, %11
br i1 %12, label %18, label %13
13: ; preds = %4
%14 = load i32, i32* @stderr
%15 = load i8*, i8** %8
%16 = trunc i64 %5 to i32
%17 = tail call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.8, i64 0, i64 0), i32 %16, i8* %15)
br label %18
18: ; preds = %13, %4
%19 = phi i32 [ 0, %13 ], [ %7, %4 ]
%20 = getelementptr inbounds i8*, i8** %8, i64 1
%21 = add nuw i64 %5, 1
%22 = load i8*, i8** %20
%23 = icmp eq i8* %22, null
br i1 %23, label %24, label %4
24: ; preds = %18
ret i32 %19
}