#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 */
int write(int, void *, int);
int trasmetti_opzione(int id_connessione, char buffer_r) {
  int count = 0;
  int byte_scritti = 0;
  void *buffer = &buffer_r;
  int dimensione = sizeof(char);
  while (count < dimensione) {
    if ((byte_scritti = write(id_connessione, buffer, dimensione - count)) >
        0) {
      count += byte_scritti;
      buffer += byte_scritti;
    } else
      return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<trasmetti_opzione>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %sil,%al
mov    %edi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    -0x9(%rbp),%rax
mov    %rax,-0x20(%rbp)
movl   $0x1,-0x24(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    1198 <trasmetti_opzione+0x88>
mov    -0x8(%rbp),%edi
mov    -0x20(%rbp),%rsi
mov    -0x24(%rbp),%edx
sub    -0x10(%rbp),%edx
call   1030 <write@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jle    1187 <trasmetti_opzione+0x77>
mov    -0x14(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x14(%rbp),%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
jmp    1193 <trasmetti_opzione+0x83>
movl   $0x1,-0x4(%rbp)
jmp    119f <trasmetti_opzione+0x8f>
jmp    113e <trasmetti_opzione+0x2e>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<trasmetti_opzione>:
push   %rax
mov    %sil,0x7(%rsp)
lea    0x7(%rsp),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
xor    %ecx,%ecx
test   %eax,%eax
setle  %cl
mov    %ecx,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @trasmetti_opzione(i32 %0, i8 signext %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
store i32 %0, i32* %4
store i8 %1, i8* %5
store i32 0, i32* %6
store i32 0, i32* %7
store i8* %5, i8** %8
store i32 1, i32* %9
br label %10
10: ; preds = %31, %2
%11 = load i32, i32* %6
%12 = load i32, i32* %9
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %32
14: ; preds = %10
%15 = load i32, i32* %4
%16 = load i8*, i8** %8
%17 = load i32, i32* %9
%18 = load i32, i32* %6
%19 = sub nsw i32 %17, %18
%20 = call i32 @write(i32 %15, i8* %16, i32 %19)
store i32 %20, i32* %7
%21 = icmp sgt i32 %20, 0
br i1 %21, label %22, label %30
22: ; preds = %14
%23 = load i32, i32* %7
%24 = load i32, i32* %6
%25 = add nsw i32 %24, %23
store i32 %25, i32* %6
%26 = load i32, i32* %7
%27 = load i8*, i8** %8
%28 = sext i32 %26 to i64
%29 = getelementptr i8, i8* %27, i64 %28
store i8* %29, i8** %8
br label %31
30: ; preds = %14
store i32 1, i32* %3
br label %33
31: ; preds = %22
br label %10
32: ; preds = %10
store i32 0, i32* %3
br label %33
33: ; preds = %32, %30
%34 = load i32, i32* %3
ret i32 %34
}

LLVM IR (-O2):
define i32 @trasmetti_opzione(i32 %0, i8 signext %1) {
%3 = alloca i8
store i8 %1, i8* %3
%4 = call i32 @write(i32 %0, i8* %3, i32 1)
%5 = icmp slt i32 %4, 1
%6 = zext i1 %5 to i32
ret i32 %6
}