#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 */
typedef char *rel;
typedef char *lrel;
typedef char *lexchange;
typedef char *lbase;
typedef char *exchange;
typedef char *base;

/* Variables and functions */
int /*<<< orphan*/ sprintf(char *, char *, char *, char *, char *);
int strcpy(char *, char *);
int /*<<< orphan*/ tolowercase(char *);
void set_dbname(char *dbname, char *exchange, char *base, char *rel) {
  char lexchange[512], lbase[512], lrel[512];
  strcpy(lexchange, exchange), tolowercase(lexchange);
  strcpy(lbase, base), tolowercase(lbase);
  strcpy(lrel, rel), tolowercase(lrel);
  sprintf(dbname, "%s.%s_%s", lexchange, lbase, lrel);
}


x86 assembly (clang, -O0):
<set_dbname>:
push   %rbp
mov    %rsp,%rbp
sub    $0x620,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
lea    -0x220(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x220(%rbp),%rdi
call   1040 <tolowercase@plt>
lea    -0x420(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x420(%rbp),%rdi
call   1040 <tolowercase@plt>
lea    -0x620(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x620(%rbp),%rdi
call   1040 <tolowercase@plt>
mov    -0x8(%rbp),%rdi
lea    -0x220(%rbp),%rdx
lea    -0x420(%rbp),%rcx
lea    -0x620(%rbp),%r8
lea    0xe41(%rip),%rsi
call   1050 <sprintf@plt>
add    $0x620,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_dbname>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x600,%rsp
mov    %rcx,%r12
mov    %rdx,%rbx
mov    %rdi,%r15
lea    0x400(%rsp),%r14
mov    %r14,%rdi
call   1030 <strcpy@plt>
mov    %r14,%rdi
call   1040 <tolowercase@plt>
lea    0x200(%rsp),%r13
mov    %r13,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    %r13,%rdi
call   1040 <tolowercase@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %r12,%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
call   1040 <tolowercase@plt>
lea    0xe67(%rip),%rsi
mov    %r15,%rdi
mov    %r14,%rdx
mov    %r13,%rcx
mov    %rbx,%r8
call   1050 <sprintf@plt>
add    $0x600,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [9 x i8] c"%s.%s_%s\00"
define void @set_dbname(i8* %0, i8* %1, i8* %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca [512 x i8]
%10 = alloca [512 x i8]
%11 = alloca [512 x i8]
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i8* %3, i8** %8
%12 = getelementptr inbounds [512 x i8], [512 x i8]* %9, i64 0, i64 0
%13 = load i8*, i8** %6
%14 = call i32 @strcpy(i8* %12, i8* %13)
%15 = getelementptr inbounds [512 x i8], [512 x i8]* %9, i64 0, i64 0
%16 = call i32 @tolowercase(i8* %15)
%17 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%18 = load i8*, i8** %7
%19 = call i32 @strcpy(i8* %17, i8* %18)
%20 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%21 = call i32 @tolowercase(i8* %20)
%22 = getelementptr inbounds [512 x i8], [512 x i8]* %11, i64 0, i64 0
%23 = load i8*, i8** %8
%24 = call i32 @strcpy(i8* %22, i8* %23)
%25 = getelementptr inbounds [512 x i8], [512 x i8]* %11, i64 0, i64 0
%26 = call i32 @tolowercase(i8* %25)
%27 = load i8*, i8** %5
%28 = getelementptr inbounds [512 x i8], [512 x i8]* %9, i64 0, i64 0
%29 = getelementptr inbounds [512 x i8], [512 x i8]* %10, i64 0, i64 0
%30 = getelementptr inbounds [512 x i8], [512 x i8]* %11, i64 0, i64 0
%31 = call i32 @sprintf(i8* %27, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %28, i8* %29, i8* %30)
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] c"%s.%s_%s\00"
define void @set_dbname(i8* nocapture writeonly %0, i8* %1, i8* %2, i8* %3) {
%5 = alloca [512 x i8]
%6 = alloca [512 x i8]
%7 = alloca [512 x i8]
%8 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%9 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%10 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%11 = call i32 @strcpy(i8* %8, i8* %1)
%12 = call i32 @tolowercase(i8* %8)
%13 = call i32 @strcpy(i8* %9, i8* %2)
%14 = call i32 @tolowercase(i8* %9)
%15 = call i32 @strcpy(i8* %10, i8* %3)
%16 = call i32 @tolowercase(i8* %10)
%17 = call i32 @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %8, i8* %9, i8* %10)
ret void
}