#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 *getenv(char *);
int /*<<< orphan*/ snprintf(char *, size_t, char *, char const *);
int /*<<< orphan*/ strncpy(char *, char const *, size_t);
void get_content_type(char *buf, size_t buflen) {
  static const char DEFAULT_CONTENT_TYPE[] =
      "Content-Type:application/octet-stream";
  const char *ev = getenv("UDPXY_CONTENT_TYPE");
  if (ev && *ev)
    (void)snprintf(buf, buflen - 1, "Content-Type:%s", ev);
  else
    strncpy(buf, DEFAULT_CONTENT_TYPE, buflen);
  buf[buflen - 1] = '\0';
}


x86 assembly (clang, -O0):
<get_content_type>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xedf(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     118c <get_content_type+0x5c>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     118c <get_content_type+0x5c>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
sub    $0x1,%rsi
mov    -0x18(%rbp),%rcx
lea    0xeb7(%rip),%rdx
call   1050 <snprintf@plt>
jmp    11a0 <get_content_type+0x70>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xe65(%rip),%rsi
call   1040 <strncpy@plt>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    $0x1,%rcx
movb   $0x0,(%rax,%rcx,1)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_content_type>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
lea    0xee5(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     116b <get_content_type+0x3b>
cmpb   $0x0,(%rax)
je     116b <get_content_type+0x3b>
add    $0xffffffffffffffff,%rbx
lea    0xede(%rip),%rdx
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %rax,%rcx
call   1050 <snprintf@plt>
jmp    1181 <get_content_type+0x51>
lea    0xe8e(%rip),%rsi
mov    %r14,%rdi
mov    %rbx,%rdx
call   1040 <strncpy@plt>
add    $0xffffffffffffffff,%rbx
movb   $0x0,(%r14,%rbx,1)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@get_content_type.DEFAULT_CONTENT_TYPE = internal constant [38 x i8] c"Content-Type:application/octet-stream\00"
@.str = [19 x i8] c"UDPXY_CONTENT_TYPE\00"
@.str.1 = [16 x i8] c"Content-Type:%s\00"
define void @get_content_type(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i8*
store i8* %0, i8** %3
store i64 %1, i64* %4
%6 = call i8* @getenv(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
store i8* %6, i8** %5
%7 = load i8*, i8** %5
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %20
9: ; preds = %2
%10 = load i8*, i8** %5
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %20
14: ; preds = %9
%15 = load i8*, i8** %3
%16 = load i64, i64* %4
%17 = sub i64 %16, 1
%18 = load i8*, i8** %5
%19 = call i32 @snprintf(i8* %15, i64 %17, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %18)
br label %24
20: ; preds = %9, %2
%21 = load i8*, i8** %3
%22 = load i64, i64* %4
%23 = call i32 @strncpy(i8* %21, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @get_content_type.DEFAULT_CONTENT_TYPE, i64 0, i64 0), i64 %22)
br label %24
24: ; preds = %20, %14
%25 = load i8*, i8** %3
%26 = load i64, i64* %4
%27 = sub i64 %26, 1
%28 = getelementptr inbounds i8, i8* %25, i64 %27
store i8 0, i8* %28
ret void
}

LLVM IR (-O2):
@get_content_type.DEFAULT_CONTENT_TYPE = internal constant [38 x i8] c"Content-Type:application/octet-stream\00"
@.str = [19 x i8] c"UDPXY_CONTENT_TYPE\00"
@.str.1 = [16 x i8] c"Content-Type:%s\00"
define void @get_content_type(i8* %0, i64 %1) {
%3 = tail call i8* @getenv(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i8* %3, null
br i1 %4, label %11, label %5
5: ; preds = %2
%6 = load i8, i8* %3
%7 = icmp eq i8 %6, 0
br i1 %7, label %11, label %8
8: ; preds = %5
%9 = add i64 %1, -1
%10 = tail call i32 @snprintf(i8* %0, i64 %9, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %3)
br label %14
11: ; preds = %5, %2
%12 = tail call i32 @strncpy(i8* %0, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @get_content_type.DEFAULT_CONTENT_TYPE, i64 0, i64 0), i64 %1)
%13 = add i64 %1, -1
br label %14
14: ; preds = %11, %8
%15 = phi i64 [ %13, %11 ], [ %9, %8 ]
%16 = getelementptr inbounds i8, i8* %0, i64 %15
store i8 0, i8* %16
ret void
}