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

/* Variables and functions */
int /*<<< orphan*/ write_mode(int /*<<< orphan*/);
int /*<<< orphan*/ write_sync();
int /*<<< orphan*/ write_to_system(int /*<<< orphan*/);
int /*<<< orphan*/ write_to_unit(char);
void write_setting(uint8_t system, char unit, uint8_t mode) {
  int i;
  for (i = 0; i < 5; i++) {
    write_to_system(system);
    write_to_unit(unit);
    write_mode(mode);
    write_sync();
  }
}


x86 assembly (clang, -O0):
<write_setting>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %sil,%al
mov    %edi,-0x4(%rbp)
mov    %al,-0x5(%rbp)
mov    %edx,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x5,-0x10(%rbp)
jge    1193 <write_setting+0x53>
mov    -0x4(%rbp),%edi
call   1030 <write_to_system@plt>
movsbl -0x5(%rbp),%edi
call   1050 <write_to_unit@plt>
mov    -0xc(%rbp),%edi
call   1060 <write_mode@plt>
mov    $0x0,%al
call   1040 <write_sync@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    115b <write_setting+0x1b>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_setting>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%r14d
mov    %esi,%ebp
mov    %edi,%ebx
call   1030 <write_to_system@plt>
mov    %ebp,%edi
call   1050 <write_to_unit@plt>
mov    %r14d,%edi
call   1060 <write_mode@plt>
xor    %eax,%eax
call   1040 <write_sync@plt>
mov    %ebx,%edi
call   1030 <write_to_system@plt>
mov    %ebp,%edi
call   1050 <write_to_unit@plt>
mov    %r14d,%edi
call   1060 <write_mode@plt>
xor    %eax,%eax
call   1040 <write_sync@plt>
mov    %ebx,%edi
call   1030 <write_to_system@plt>
mov    %ebp,%edi
call   1050 <write_to_unit@plt>
mov    %r14d,%edi
call   1060 <write_mode@plt>
xor    %eax,%eax
call   1040 <write_sync@plt>
mov    %ebx,%edi
call   1030 <write_to_system@plt>
mov    %ebp,%edi
call   1050 <write_to_unit@plt>
mov    %r14d,%edi
call   1060 <write_mode@plt>
xor    %eax,%eax
call   1040 <write_sync@plt>
mov    %ebx,%edi
call   1030 <write_to_system@plt>
mov    %ebp,%edi
call   1050 <write_to_unit@plt>
mov    %r14d,%edi
call   1060 <write_mode@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <write_sync@plt>

LLVM IR (-O0):
define void @write_setting(i32 %0, i8 signext %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %4
store i8 %1, i8* %5
store i32 %2, i32* %6
store i32 0, i32* %7
br label %8
8: ; preds = %19, %3
%9 = load i32, i32* %7
%10 = icmp slt i32 %9, 5
br i1 %10, label %11, label %22
11: ; preds = %8
%12 = load i32, i32* %4
%13 = call i32 @write_to_system(i32 %12)
%14 = load i8, i8* %5
%15 = call i32 @write_to_unit(i8 signext %14)
%16 = load i32, i32* %6
%17 = call i32 @write_mode(i32 %16)
%18 = call i32 (...) @write_sync()
br label %19
19: ; preds = %11
%20 = load i32, i32* %7
%21 = add nsw i32 %20, 1
store i32 %21, i32* %7
br label %8
22: ; preds = %8
ret void
}

LLVM IR (-O2):
define void @write_setting(i32 %0, i8 signext %1, i32 %2) {
%4 = tail call i32 @write_to_system(i32 %0)
%5 = tail call i32 @write_to_unit(i8 signext %1)
%6 = tail call i32 @write_mode(i32 %2)
%7 = tail call i32 (...) @write_sync()
%8 = tail call i32 @write_to_system(i32 %0)
%9 = tail call i32 @write_to_unit(i8 signext %1)
%10 = tail call i32 @write_mode(i32 %2)
%11 = tail call i32 (...) @write_sync()
%12 = tail call i32 @write_to_system(i32 %0)
%13 = tail call i32 @write_to_unit(i8 signext %1)
%14 = tail call i32 @write_mode(i32 %2)
%15 = tail call i32 (...) @write_sync()
%16 = tail call i32 @write_to_system(i32 %0)
%17 = tail call i32 @write_to_unit(i8 signext %1)
%18 = tail call i32 @write_mode(i32 %2)
%19 = tail call i32 (...) @write_sync()
%20 = tail call i32 @write_to_system(i32 %0)
%21 = tail call i32 @write_to_unit(i8 signext %1)
%22 = tail call i32 @write_mode(i32 %2)
%23 = tail call i32 (...) @write_sync()
ret void
}