#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 */
typedef int uint8_t;

/* Variables and functions */
int atoi(char const *);
scalar_t__ vito_write(int, int, int *);
const char *const write_mode(const char *value_str) {
  uint8_t content[3];
  int mode;
  mode = atoi(value_str);
  if (mode < 0 || mode > 2)
    return "Illegal Mode!";
  content[0] = mode & 0xff;
  if (vito_write(0x2323, 1, content) < 0)
    return "Vitodens communication Error";
  else
    return "OK";
}


x86 assembly (clang, -O0):
<write_mode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <atoi@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jl     114c <write_mode+0x2c>
cmpl   $0x2,-0x20(%rbp)
jle    115c <write_mode+0x3c>
lea    0xead(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    119f <write_mode+0x7f>
mov    -0x20(%rbp),%eax
and    $0xff,%eax
mov    %eax,-0x1c(%rbp)
lea    -0x1c(%rbp),%rdx
mov    $0x2323,%edi
mov    $0x1,%esi
call   1040 <vito_write@plt>
cmp    $0x0,%rax
jge    1194 <write_mode+0x74>
lea    0xe83(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    119f <write_mode+0x7f>
lea    0xe90(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_mode>:
sub    $0x18,%rsp
call   1030 <atoi@plt>
cmp    $0x2,%eax
jbe    113a <write_mode+0x1a>
lea    0xecb(%rip),%rax
add    $0x18,%rsp
ret
mov    %eax,0xc(%rsp)
lea    0xc(%rsp),%rdx
mov    $0x2323,%edi
mov    $0x1,%esi
call   1040 <vito_write@plt>
test   %rax,%rax
lea    0xeb2(%rip),%rcx
lea    0xec8(%rip),%rax
cmovs  %rcx,%rax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [14 x i8] c"Illegal Mode!\00"
@.str.1 = [29 x i8] c"Vitodens communication Error\00"
@.str.2 = [3 x i8] c"OK\00"
define i8* @write_mode(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca [3 x i32]
%5 = alloca i32
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = call i32 @atoi(i8* %6)
store i32 %7, i32* %5
%8 = load i32, i32* %5
%9 = icmp slt i32 %8, 0
br i1 %9, label %13, label %10
10: ; preds = %1
%11 = load i32, i32* %5
%12 = icmp sgt i32 %11, 2
br i1 %12, label %13, label %14
13: ; preds = %10, %1
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8** %2
br label %23
14: ; preds = %10
%15 = load i32, i32* %5
%16 = and i32 %15, 255
%17 = getelementptr inbounds [3 x i32], [3 x i32]* %4, i64 0, i64 0
store i32 %16, i32* %17
%18 = getelementptr inbounds [3 x i32], [3 x i32]* %4, i64 0, i64 0
%19 = call i64 @vito_write(i32 8995, i32 1, i32* %18)
%20 = icmp slt i64 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %14
store i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %23
22: ; preds = %14
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %23
23: ; preds = %22, %21, %13
%24 = load i8*, i8** %2
ret i8* %24
}

LLVM IR (-O2):
@.str = [14 x i8] c"Illegal Mode!\00"
@.str.1 = [29 x i8] c"Vitodens communication Error\00"
@.str.2 = [3 x i8] c"OK\00"
define i8* @write_mode(i8* nocapture %0) {
%2 = alloca [3 x i32]
%3 = bitcast [3 x i32]* %2 to i8*
%4 = tail call i32 @atoi(i8* %0)
%5 = icmp ugt i32 %4, 2
br i1 %5, label %11, label %6
6: ; preds = %1
%7 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 0
store i32 %4, i32* %7
%8 = call i64 @vito_write(i32 8995, i32 1, i32* %7)
%9 = icmp slt i64 %8, 0
%10 = select i1 %9, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0)
br label %11
11: ; preds = %6, %1
%12 = phi i8* [ getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), %1 ], [ %10, %6 ]
ret i8* %12
}