#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 */
scalar_t__ malloc(int);
int /*<<< orphan*/ sprintf(char *, char *, int, ...);
int sscanf(char *, char *, int *, int *);
char *comma() {
  int major, minor;
  char *version_string;
  version_string = (char *)malloc(11);
  if (sscanf("1499-6", "%d-%d", &major, &minor) > 1) {
    sprintf(version_string, "%d,%d,0,0", major, minor);
  } else {
    sprintf(version_string, "%d,0,0,0", major);
  }
  return version_string;
}


x86 assembly (clang, -O0):
<comma>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0xb,%edi
call   1030 <malloc@plt>
mov    %rax,-0x10(%rbp)
lea    0xeb3(%rip),%rdi
lea    0xeb3(%rip),%rsi
lea    -0x4(%rbp),%rdx
lea    -0x8(%rbp),%rcx
call   1040 <sscanf@plt>
cmp    $0x1,%eax
jle    1187 <comma+0x57>
mov    -0x10(%rbp),%rdi
mov    -0x4(%rbp),%edx
mov    -0x8(%rbp),%ecx
lea    0xe92(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
jmp    119c <comma+0x6c>
mov    -0x10(%rbp),%rdi
mov    -0x4(%rbp),%edx
lea    0xe82(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<comma>:
push   %rbx
sub    $0x10,%rsp
mov    $0xb,%edi
call   1030 <malloc@plt>
mov    %rax,%rbx
lea    0xeb7(%rip),%rdi
lea    0xeb7(%rip),%rsi
lea    0xc(%rsp),%rdx
lea    0x8(%rsp),%rcx
call   1040 <sscanf@plt>
mov    0xc(%rsp),%edx
cmp    $0x2,%eax
jl     117f <comma+0x4f>
mov    0x8(%rsp),%ecx
lea    0xe9a(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <sprintf@plt>
jmp    1190 <comma+0x60>
lea    0xe91(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <sprintf@plt>
mov    %rbx,%rax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [7 x i8] c"1499-6\00"
@.str.1 = [6 x i8] c"%d-%d\00"
@.str.2 = [10 x i8] c"%d,%d,0,0\00"
@.str.3 = [9 x i8] c"%d,0,0,0\00"
define i8* @comma() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
%4 = call i64 @malloc(i32 11)
%5 = inttoptr i64 %4 to i8*
store i8* %5, i8** %3
%6 = call i32 @sscanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %1, i32* %2)
%7 = icmp sgt i32 %6, 1
br i1 %7, label %8, label %13
8: ; preds = %0
%9 = load i8*, i8** %3
%10 = load i32, i32* %1
%11 = load i32, i32* %2
%12 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %9, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %10, i32 %11)
br label %17
13: ; preds = %0
%14 = load i8*, i8** %3
%15 = load i32, i32* %1
%16 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %14, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %15)
br label %17
17: ; preds = %13, %8
%18 = load i8*, i8** %3
ret i8* %18
}

LLVM IR (-O2):
@.str = [7 x i8] c"1499-6\00"
@.str.1 = [6 x i8] c"%d-%d\00"
@.str.2 = [10 x i8] c"%d,%d,0,0\00"
@.str.3 = [9 x i8] c"%d,0,0,0\00"
define i8* @comma() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i64 @malloc(i32 11)
%6 = inttoptr i64 %5 to i8*
%7 = call i32 @sscanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %1, i32* %2)
%8 = icmp sgt i32 %7, 1
%9 = load i32, i32* %1
br i1 %8, label %10, label %13
10: ; preds = %0
%11 = load i32, i32* %2
%12 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* dereferenceable(1) %6, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %9, i32 %11)
br label %15
13: ; preds = %0
%14 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* dereferenceable(1) %6, i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %9)
br label %15
15: ; preds = %13, %10
ret i8* %6
}