#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 mls_conf {
  int dummy;
};

/* Variables and functions */
int mls_conf_set(struct mls_conf *, char *, char *);
int /*<<< orphan*/ mls_conf_store(struct mls_conf *);
int /*<<< orphan*/ mls_type_data_ushort_to_str(char *, unsigned short);
int /*<<< orphan*/ sprintf(char *, char *, unsigned char);
int mls_type_data_put_ushort(struct mls_conf *storage, unsigned char epc,
                             unsigned short inb) {
  int ret = 0;
  char key[2 + 1];
  char val[2 * 2 + 1];
  sprintf(key, "%02X", epc);
  mls_type_data_ushort_to_str(val, inb);
  ret = mls_conf_set(storage, key, val);
  if (ret != 0) {
    goto out;
  }
  mls_conf_store(storage);
out:
  return ret;
}


x86 assembly (clang, -O0):
<mls_type_data_put_ushort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dx,%ax
mov    %sil,%cl
mov    %rdi,-0x8(%rbp)
mov    %cl,-0x9(%rbp)
mov    %ax,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
lea    -0x13(%rbp),%rdi
lea    0xe95(%rip),%rsi
movzbl -0x9(%rbp),%edx
call   1060 <sprintf@plt>
lea    -0x18(%rbp),%rdi
movzwl -0xc(%rbp),%esi
call   1040 <mls_type_data_ushort_to_str@plt>
mov    -0x8(%rbp),%rdi
lea    -0x13(%rbp),%rsi
lea    -0x18(%rbp),%rdx
call   1050 <mls_conf_set@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     11a4 <mls_type_data_put_ushort+0x64>
jmp    11ad <mls_type_data_put_ushort+0x6d>
mov    -0x8(%rbp),%rdi
call   1030 <mls_conf_store@plt>
mov    -0x10(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mls_type_data_put_ushort>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%ebp
mov    %esi,%edx
mov    %rdi,%r15
lea    0xeab(%rip),%rsi
mov    %rsp,%r14
mov    %r14,%rdi
call   1060 <sprintf@plt>
lea    0x3(%rsp),%rbx
mov    %rbx,%rdi
mov    %ebp,%esi
call   1040 <mls_type_data_ushort_to_str@plt>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
call   1050 <mls_conf_set@plt>
mov    %eax,%ebp
test   %eax,%eax
jne    118b <mls_type_data_put_ushort+0x4b>
mov    %r15,%rdi
call   1030 <mls_conf_store@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.mls_conf = type { i32 }
@.str = [5 x i8] c"%02X\00"
define i32 @mls_type_data_put_ushort(%struct.mls_conf* %0, i8 zeroext %1, i16 zeroext %2) {
%4 = alloca %struct.mls_conf*
%5 = alloca i8
%6 = alloca i16
%7 = alloca i32
%8 = alloca [3 x i8]
%9 = alloca [5 x i8]
store %struct.mls_conf* %0, %struct.mls_conf** %4
store i8 %1, i8* %5
store i16 %2, i16* %6
store i32 0, i32* %7
%10 = getelementptr inbounds [3 x i8], [3 x i8]* %8, i64 0, i64 0
%11 = load i8, i8* %5
%12 = call i32 @sprintf(i8* %10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 zeroext %11)
%13 = getelementptr inbounds [5 x i8], [5 x i8]* %9, i64 0, i64 0
%14 = load i16, i16* %6
%15 = call i32 @mls_type_data_ushort_to_str(i8* %13, i16 zeroext %14)
%16 = load %struct.mls_conf*, %struct.mls_conf** %4
%17 = getelementptr inbounds [3 x i8], [3 x i8]* %8, i64 0, i64 0
%18 = getelementptr inbounds [5 x i8], [5 x i8]* %9, i64 0, i64 0
%19 = call i32 @mls_conf_set(%struct.mls_conf* %16, i8* %17, i8* %18)
store i32 %19, i32* %7
%20 = load i32, i32* %7
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %3
br label %26
23: ; preds = %3
%24 = load %struct.mls_conf*, %struct.mls_conf** %4
%25 = call i32 @mls_conf_store(%struct.mls_conf* %24)
br label %26
26: ; preds = %23, %22
%27 = load i32, i32* %7
ret i32 %27
}

LLVM IR (-O2):
%struct.mls_conf = type { i32 }
@.str = [5 x i8] c"%02X\00"
define i32 @mls_type_data_put_ushort(%struct.mls_conf* %0, i8 zeroext %1, i16 zeroext %2) {
%4 = alloca [3 x i8]
%5 = alloca [5 x i8]
%6 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 0
%7 = getelementptr inbounds [5 x i8], [5 x i8]* %5, i64 0, i64 0
%8 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 zeroext %1)
%9 = call i32 @mls_type_data_ushort_to_str(i8* %7, i16 zeroext %2)
%10 = call i32 @mls_conf_set(%struct.mls_conf* %0, i8* %6, i8* %7)
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %3
%13 = call i32 @mls_conf_store(%struct.mls_conf* %0)
br label %14
14: ; preds = %3, %12
ret i32 %10
}