#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*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int sprintf(char *, char *, char *, char *);
int /*<<< orphan*/ stderr;
void addExtension(char *fname, char *extension, char *target) {
  if (sprintf(target, "%s.%s", fname, extension) >= 1000) {
    fprintf(stderr, "Argument outFile is too long\n");
    exit(EXIT_FAILURE);
  }
}


x86 assembly (clang, -O0):
<addExtension>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    0xea9(%rip),%rsi
call   1040 <sprintf@plt>
cmp    $0x3e8,%eax
jl     118a <addExtension+0x5a>
mov    0x2e72(%rip),%rax
mov    (%rax),%edi
lea    0xe8f(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2e55(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<addExtension>:
push   %rax
mov    %rsi,%rcx
mov    %rdi,%rax
lea    0xec2(%rip),%rsi
mov    %rdx,%rdi
mov    %rax,%rdx
call   1040 <sprintf@plt>
cmp    $0x3e8,%eax
jge    1152 <addExtension+0x22>
pop    %rax
ret
mov    0x2e87(%rip),%rax
mov    (%rax),%edi
lea    0xea4(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2e6a(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"%s.%s\00"
@stderr = global i32 0
@.str.1 = [30 x i8] c"Argument outFile is too long\0A\00"
@EXIT_FAILURE = global i32 0
define void @addExtension(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%7 = load i8*, i8** %6
%8 = load i8*, i8** %4
%9 = load i8*, i8** %5
%10 = call i32 @sprintf(i8* %7, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %8, i8* %9)
%11 = icmp sge i32 %10, 1000
br i1 %11, label %12, label %17
12: ; preds = %3
%13 = load i32, i32* @stderr
%14 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
%15 = load i32, i32* @EXIT_FAILURE
%16 = call i32 @exit(i32 %15)
unreachable
17: ; preds = %3
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"%s.%s\00"
@stderr = global i32 0
@.str.1 = [30 x i8] c"Argument outFile is too long\0A\00"
@EXIT_FAILURE = global i32 0
define void @addExtension(i8* %0, i8* %1, i8* nocapture writeonly %2) {
%4 = tail call i32 @sprintf(i8* dereferenceable(1) %2, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %1)
%5 = icmp sgt i32 %4, 999
br i1 %5, label %6, label %11
6: ; preds = %3
%7 = load i32, i32* @stderr
%8 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
%9 = load i32, i32* @EXIT_FAILURE
%10 = tail call i32 @exit(i32 %9)
unreachable
11: ; preds = %3
ret void
}