#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 */
struct sysentry {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ is_smt_capable();
int parse_smt_state();
int /*<<< orphan*/ sprintf(char *, char *, ...);
int /*<<< orphan*/ stderr;
void get_smt_mode(struct sysentry *se, char *buf) {
  int smt_state = 0;
  if (!is_smt_capable()) {
    sprintf(buf, "1");
    return;
  }
  smt_state = parse_smt_state();
  if (smt_state < 0) {
    fprintf(stderr, "Failed to get smt state\n");
    return;
  }
  if (smt_state == 1)
    sprintf(buf, "Off");
  else
    sprintf(buf, "%d", smt_state);
}


x86 assembly (clang, -O0):
<get_smt_mode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    $0x0,%al
call   1060 <is_smt_capable@plt>
cmp    $0x0,%eax
jne    117e <get_smt_mode+0x3e>
mov    -0x10(%rbp),%rdi
lea    0xe8e(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
jmp    11e2 <get_smt_mode+0xa2>
mov    $0x0,%al
call   1030 <parse_smt_state@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    11ac <get_smt_mode+0x6c>
mov    0x2e47(%rip),%rax
mov    (%rax),%edi
lea    0xe60(%rip),%rsi
call   1040 <fprintf@plt>
jmp    11e2 <get_smt_mode+0xa2>
cmpl   $0x1,-0x14(%rbp)
jne    11cd <get_smt_mode+0x8d>
mov    -0x10(%rbp),%rdi
lea    0xe5a(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
jmp    11e2 <get_smt_mode+0xa2>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0xe44(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_smt_mode>:
push   %rbx
mov    %rsi,%rbx
xor    %eax,%eax
call   1060 <is_smt_capable@plt>
test   %eax,%eax
je     1167 <get_smt_mode+0x27>
xor    %eax,%eax
call   1030 <parse_smt_state@plt>
test   %eax,%eax
js     116e <get_smt_mode+0x2e>
cmp    $0x1,%eax
jne    1184 <get_smt_mode+0x44>
movl   $0x66664f,(%rbx)
pop    %rbx
ret
movw   $0x31,(%rbx)
pop    %rbx
ret
mov    0x2e6b(%rip),%rax
mov    (%rax),%edi
lea    0xe82(%rip),%rsi
pop    %rbx
jmp    1040 <fprintf@plt>
lea    0xe8e(%rip),%rsi
mov    %rbx,%rdi
mov    %eax,%edx
xor    %eax,%eax
pop    %rbx
jmp    1050 <sprintf@plt>

LLVM IR (-O0):
%struct.sysentry = type { i32 }
@.str = [2 x i8] c"1\00"
@stderr = global i32 0
@.str.1 = [25 x i8] c"Failed to get smt state\0A\00"
@.str.2 = [4 x i8] c"Off\00"
@.str.3 = [3 x i8] c"%d\00"
define void @get_smt_mode(%struct.sysentry* %0, i8* %1) {
%3 = alloca %struct.sysentry*
%4 = alloca i8*
%5 = alloca i32
store %struct.sysentry* %0, %struct.sysentry** %3
store i8* %1, i8** %4
store i32 0, i32* %5
%6 = call i32 (...) @is_smt_capable()
%7 = icmp ne i32 %6, 0
br i1 %7, label %11, label %8
8: ; preds = %2
%9 = load i8*, i8** %4
%10 = call i32 (i8*, i8*, ...) @sprintf(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %28
11: ; preds = %2
%12 = call i32 (...) @parse_smt_state()
store i32 %12, i32* %5
%13 = load i32, i32* %5
%14 = icmp slt i32 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %11
%16 = load i32, i32* @stderr
%17 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
br label %28
18: ; preds = %11
%19 = load i32, i32* %5
%20 = icmp eq i32 %19, 1
br i1 %20, label %21, label %24
21: ; preds = %18
%22 = load i8*, i8** %4
%23 = call i32 (i8*, i8*, ...) @sprintf(i8* %22, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %28
24: ; preds = %18
%25 = load i8*, i8** %4
%26 = load i32, i32* %5
%27 = call i32 (i8*, i8*, ...) @sprintf(i8* %25, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %26)
br label %28
28: ; preds = %8, %15, %24, %21
ret void
}

LLVM IR (-O2):
%struct.sysentry = type { i32 }
@stderr = global i32 0
@.str.1 = [25 x i8] c"Failed to get smt state\0A\00"
@.str.3 = [3 x i8] c"%d\00"
define void @get_smt_mode(%struct.sysentry* nocapture readnone %0, i8* nocapture writeonly %1) {
%3 = tail call i32 (...) @is_smt_capable()
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = bitcast i8* %1 to i16*
store i16 49, i16* %6
br label %19
7: ; preds = %2
%8 = tail call i32 (...) @parse_smt_state()
%9 = icmp slt i32 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %7
%11 = load i32, i32* @stderr
%12 = tail call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
br label %19
13: ; preds = %7
%14 = icmp eq i32 %8, 1
br i1 %14, label %15, label %17
15: ; preds = %13
%16 = bitcast i8* %1 to i32*
store i32 6710863, i32* %16
br label %19
17: ; preds = %13
%18 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %1, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %8)
br label %19
19: ; preds = %15, %17, %10, %5
ret void
}