#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 *read_string(char *, char *);
int /*<<< orphan*/ strcmp(char const *, char *);
int get_platform(void) {
  const char *platform = read_string("DEFAULT", "platform");
  if (platform) {
    if (!strcmp(platform, "dpdk"))
      return 2;
    else if (!strcmp(platform, "nic"))
      return 3;
    else
      return 1;
  }
  return 1;
}


x86 assembly (clang, -O0):
<get_platform>:
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     11a0 <get_platform+0x80>
mov    -0x10(%rbp),%rdi
lea    0xebc(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    116f <get_platform+0x4f>
movl   $0x2,-0x4(%rbp)
jmp    11a7 <get_platform+0x87>
mov    -0x10(%rbp),%rdi
lea    0xe9c(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    1194 <get_platform+0x74>
movl   $0x3,-0x4(%rbp)
jmp    11a7 <get_platform+0x87>
movl   $0x1,-0x4(%rbp)
jmp    11a7 <get_platform+0x87>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_platform>:
push   %rbx
lea    0xed8(%rip),%rdi
lea    0xed9(%rip),%rsi
call   1040 <read_string@plt>
test   %rax,%rax
je     116d <get_platform+0x4d>
mov    %rax,%rbx
lea    0xece(%rip),%rsi
mov    %rax,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     1174 <get_platform+0x54>
lea    0xec0(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
xor    %ecx,%ecx
test   %eax,%eax
sete   %cl
lea    (%rcx,%rcx,1),%eax
add    $0x1,%eax
pop    %rbx
ret
mov    $0x1,%eax
pop    %rbx
ret
mov    $0x2,%eax
pop    %rbx
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"
define i32 @get_platform() {
%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 %17
6: ; preds = %0
%7 = load i8*, i8** %2
%8 = call i32 @strcmp(i8* %7, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%9 = icmp ne i32 %8, 0
br i1 %9, label %11, label %10
10: ; preds = %6
store i32 2, i32* %1
br label %18
11: ; preds = %6
%12 = load i8*, i8** %2
%13 = call i32 @strcmp(i8* %12, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%14 = icmp ne i32 %13, 0
br i1 %14, label %16, label %15
15: ; preds = %11
store i32 3, i32* %1
br label %18
16: ; preds = %11
store i32 1, i32* %1
br label %18
17: ; preds = %0
store i32 1, i32* %1
br label %18
18: ; preds = %17, %16, %15, %10
%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"
define i32 @get_platform() {
%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 %10, label %3
3: ; preds = %0
%4 = tail call i32 @strcmp(i8* %1, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%5 = icmp eq i32 %4, 0
br i1 %5, label %10, label %6
6: ; preds = %3
%7 = tail call i32 @strcmp(i8* %1, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%8 = icmp eq i32 %7, 0
%9 = select i1 %8, i32 3, i32 1
br label %10
10: ; preds = %0, %6, %3
%11 = phi i32 [ 2, %3 ], [ %9, %6 ], [ 1, %0 ]
ret i32 %11
}