#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 SOCK_DGRAM;
int SOCK_STREAM;
char *read_string(char *, char *);
scalar_t__ strcmp(char const *, char *);
int get_type() {
  const char *platform = read_string("DEFAULT", "platform");
  if (platform &&
      (strcmp(platform, "dpdk") == 0 || strcmp(platform, "nic") == 0)) {
    return SOCK_STREAM;
  }
  return SOCK_DGRAM;
}


x86 assembly (clang, -O0):
<get_type>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xed1(%rip),%rdi
lea    0xed2(%rip),%rsi
call   1040 <read_string@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     118f <get_type+0x6f>
mov    -0x10(%rbp),%rdi
lea    0xebc(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
je     117e <get_type+0x5e>
mov    -0x10(%rbp),%rdi
lea    0xea7(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    118f <get_type+0x6f>
mov    0x2e53(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    119b <get_type+0x7b>
mov    0x2e52(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_type>:
push   %r14
push   %rbx
push   %rax
lea    0xed5(%rip),%rdi
lea    0xed6(%rip),%rsi
call   1040 <read_string@plt>
test   %rax,%rax
je     116e <get_type+0x4e>
mov    %rax,%rbx
lea    0xecb(%rip),%rsi
mov    %rax,%rdi
call   1030 <strcmp@plt>
mov    0x2e83(%rip),%r14
test   %rax,%rax
je     1175 <get_type+0x55>
lea    0xeb5(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1175 <get_type+0x55>
mov    0x2e73(%rip),%r14
mov    (%r14),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [8 x i8] c"DEFAULT\00"
@.str.1 = [9 x i8] c"platform\00"
@.str.2 = [5 x i8] c"dpdk\00"
@.str.3 = [4 x i8] c"nic\00"
@SOCK_STREAM = global i32 0
@SOCK_DGRAM = global i32 0
define i32 @get_type() {
%1 = alloca i32
%2 = alloca i8*
%3 = call i8* @read_string(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
store i8* %3, i8** %2
%4 = load i8*, i8** %2
%5 = icmp ne i8* %4, null
br i1 %5, label %6, label %16
6: ; preds = %0
%7 = load i8*, i8** %2
%8 = call i64 @strcmp(i8* %7, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %14, label %10
10: ; preds = %6
%11 = load i8*, i8** %2
%12 = call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %10, %6
%15 = load i32, i32* @SOCK_STREAM
store i32 %15, i32* %1
br label %18
16: ; preds = %10, %0
%17 = load i32, i32* @SOCK_DGRAM
store i32 %17, i32* %1
br label %18
18: ; preds = %16, %14
%19 = load i32, i32* %1
ret i32 %19
}

LLVM IR (-O2):
@.str = [8 x i8] c"DEFAULT\00"
@.str.1 = [9 x i8] c"platform\00"
@.str.2 = [5 x i8] c"dpdk\00"
@.str.3 = [4 x i8] c"nic\00"
@SOCK_STREAM = global i32 0
@SOCK_DGRAM = global i32 0
define i32 @get_type() {
%1 = tail call i8* @read_string(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%2 = icmp eq i8* %1, null
br i1 %2, label %9, label %3
3: ; preds = %0
%4 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%5 = icmp eq i64 %4, 0
br i1 %5, label %10, label %6
6: ; preds = %3
%7 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %10, label %9
9: ; preds = %6, %0
br label %10
10: ; preds = %3, %6, %9
%11 = phi i32* [ @SOCK_DGRAM, %9 ], [ @SOCK_STREAM, %6 ], [ @SOCK_STREAM, %3 ]
%12 = load i32, i32* %11
ret i32 %12
}