#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 */
char *malloc(int);
int /*<<< orphan*/ nomem();
char *strcpy(char *, char const *);
int strlen(char const *);
int /*<<< orphan*/ toupper(char const);
char *convert_to_config_uppercase(const char *pre, const char *line) {
  char *holder, *p;
  int i;
  holder = malloc(strlen(line) * 2 + strlen(pre) + 1);
  if (holder == NULL)
    nomem();
  p = strcpy(holder, pre) + strlen(pre);
  for (i = 0; i < strlen(line); i++)
    switch (line[i]) {
    case '-':
      *p++ = '_';
      break;
    default:
      *p++ = toupper(line[i]);
      break;
    }
  *p++ = '\0';
  return holder;
}


x86 assembly (clang, -O0):
<convert_to_config_uppercase>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
shl    $0x1,%eax
mov    %eax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x28(%rbp),%edi
add    %eax,%edi
add    $0x1,%edi
call   1070 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    119b <convert_to_config_uppercase+0x4b>
mov    $0x0,%al
call   1060 <nomem@plt>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x34(%rbp),%eax
cmp    %ecx,%eax
jge    124e <convert_to_config_uppercase+0xfe>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,1),%al
sub    $0x2d,%al
jne    1217 <convert_to_config_uppercase+0xc7>
jmp    1200 <convert_to_config_uppercase+0xb0>
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20(%rbp)
movb   $0x5f,(%rax)
jmp    123b <convert_to_config_uppercase+0xeb>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <toupper@plt>
mov    %al,%cl
mov    -0x20(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x20(%rbp)
mov    %cl,(%rax)
jmp    1240 <convert_to_config_uppercase+0xf0>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11cc <convert_to_config_uppercase+0x7c>
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20(%rbp)
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<convert_to_config_uppercase>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%r13
mov    %rdi,%r12
mov    %rsi,%rdi
call   1050 <strlen@plt>
mov    %eax,%r14d
mov    %r12,%rdi
call   1050 <strlen@plt>
lea    (%rax,%r14,2),%edi
add    $0x1,%edi
call   1070 <malloc@plt>
mov    %rax,%r15
mov    %rax,%r14
test   %rax,%rax
jne    1190 <convert_to_config_uppercase+0x40>
xor    %eax,%eax
call   1060 <nomem@plt>
mov    %r14,%rdi
mov    %r12,%rsi
call   1030 <strcpy@plt>
mov    %r12,%rdi
call   1050 <strlen@plt>
cltq
add    %rax,%r15
mov    %r13,%rdi
call   1050 <strlen@plt>
test   %eax,%eax
jle    11f1 <convert_to_config_uppercase+0xa1>
xor    %ebx,%ebx
jmp    11d7 <convert_to_config_uppercase+0x87>
nopl   0x0(%rax,%rax,1)
mov    %al,(%r15,%rbx,1)
add    $0x1,%rbx
mov    %r13,%rdi
call   1050 <strlen@plt>
cltq
cmp    %rax,%rbx
jge    11ee <convert_to_config_uppercase+0x9e>
movzbl 0x0(%r13,%rbx,1),%ecx
mov    $0x5f,%al
cmp    $0x2d,%cl
je     11c0 <convert_to_config_uppercase+0x70>
movsbl %cl,%edi
call   1040 <toupper@plt>
jmp    11c0 <convert_to_config_uppercase+0x70>
add    %rbx,%r15
movb   $0x0,(%r15)
mov    %r14,%rax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8* @convert_to_config_uppercase(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%8 = load i8*, i8** %4
%9 = call i32 @strlen(i8* %8)
%10 = mul nsw i32 %9, 2
%11 = load i8*, i8** %3
%12 = call i32 @strlen(i8* %11)
%13 = add nsw i32 %10, %12
%14 = add nsw i32 %13, 1
%15 = call i8* @malloc(i32 %14)
store i8* %15, i8** %5
%16 = load i8*, i8** %5
%17 = icmp eq i8* %16, null
br i1 %17, label %18, label %20
18: ; preds = %2
%19 = call i32 (...) @nomem()
br label %20
20: ; preds = %18, %2
%21 = load i8*, i8** %5
%22 = load i8*, i8** %3
%23 = call i8* @strcpy(i8* %21, i8* %22)
%24 = load i8*, i8** %3
%25 = call i32 @strlen(i8* %24)
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %23, i64 %26
store i8* %27, i8** %6
store i32 0, i32* %7
br label %28
28: ; preds = %54, %20
%29 = load i32, i32* %7
%30 = load i8*, i8** %4
%31 = call i32 @strlen(i8* %30)
%32 = icmp slt i32 %29, %31
br i1 %32, label %33, label %57
33: ; preds = %28
%34 = load i8*, i8** %4
%35 = load i32, i32* %7
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8, i8* %34, i64 %36
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
switch i32 %39, label %43 [
i32 45, label %40
]
40: ; preds = %33
%41 = load i8*, i8** %6
%42 = getelementptr inbounds i8, i8* %41, i32 1
store i8* %42, i8** %6
store i8 95, i8* %41
br label %53
43: ; preds = %33
%44 = load i8*, i8** %4
%45 = load i32, i32* %7
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i8, i8* %44, i64 %46
%48 = load i8, i8* %47
%49 = call i32 @toupper(i8 signext %48)
%50 = trunc i32 %49 to i8
%51 = load i8*, i8** %6
%52 = getelementptr inbounds i8, i8* %51, i32 1
store i8* %52, i8** %6
store i8 %50, i8* %51
br label %53
53: ; preds = %43, %40
br label %54
54: ; preds = %53
%55 = load i32, i32* %7
%56 = add nsw i32 %55, 1
store i32 %56, i32* %7
br label %28
57: ; preds = %28
%58 = load i8*, i8** %6
%59 = getelementptr inbounds i8, i8* %58, i32 1
store i8* %59, i8** %6
store i8 0, i8* %58
%60 = load i8*, i8** %5
ret i8* %60
}

LLVM IR (-O2):
define i8* @convert_to_config_uppercase(i8* %0, i8* %1) {
%3 = tail call i32 @strlen(i8* %1)
%4 = shl nsw i32 %3, 1
%5 = tail call i32 @strlen(i8* %0)
%6 = add i32 %5, 1
%7 = add i32 %6, %4
%8 = tail call i8* @malloc(i32 %7)
%9 = icmp eq i8* %8, null
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = tail call i32 (...) @nomem()
br label %12
12: ; preds = %10, %2
%13 = tail call i8* @strcpy(i8* dereferenceable(1) %8, i8* dereferenceable(1) %0)
%14 = tail call i32 @strlen(i8* %0)
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %8, i64 %15
%17 = tail call i32 @strlen(i8* %1)
%18 = icmp sgt i32 %17, 0
br i1 %18, label %19, label %35
19: ; preds = %12, %28
%20 = phi i64 [ %31, %28 ], [ 0, %12 ]
%21 = phi i8* [ %30, %28 ], [ %16, %12 ]
%22 = getelementptr inbounds i8, i8* %1, i64 %20
%23 = load i8, i8* %22
%24 = icmp eq i8 %23, 45
br i1 %24, label %28, label %25
25: ; preds = %19
%26 = tail call i32 @toupper(i8 signext %23)
%27 = trunc i32 %26 to i8
br label %28
28: ; preds = %19, %25
%29 = phi i8 [ %27, %25 ], [ 95, %19 ]
%30 = getelementptr inbounds i8, i8* %21, i64 1
store i8 %29, i8* %21
%31 = add nuw nsw i64 %20, 1
%32 = tail call i32 @strlen(i8* %1)
%33 = sext i32 %32 to i64
%34 = icmp slt i64 %31, %33
br i1 %34, label %19, label %35
35: ; preds = %28, %12
%36 = phi i8* [ %16, %12 ], [ %30, %28 ]
store i8 0, i8* %36
ret i8* %8
}