#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 ActiverRelai(int);
int DesactiverRelai(int);
int IdentifiantBoutonPlosible(int);
int StatutBoutonPlosible(int);
int ChangerStatutBouton(int identifiantBouton, int statutBouton) {
  int codeRetour = IdentifiantBoutonPlosible(identifiantBouton);
  if (codeRetour != 200)
    return codeRetour;
  codeRetour = StatutBoutonPlosible(statutBouton);
  if (codeRetour != 200)
    return codeRetour;
  if (statutBouton == 1) {
    codeRetour = ActiverRelai(identifiantBouton);
  } else if (statutBouton == 0) {
    codeRetour = DesactiverRelai(identifiantBouton);
  } else {
    return 406;
  }
  return codeRetour;
}


x86 assembly (clang, -O0):
<ChangerStatutBouton>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%edi
call   1050 <IdentifiantBoutonPlosible@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0xc8,-0x10(%rbp)
je     1171 <ChangerStatutBouton+0x31>
mov    -0x10(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11df <ChangerStatutBouton+0x9f>
mov    -0xc(%rbp),%edi
call   1060 <StatutBoutonPlosible@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0xc8,-0x10(%rbp)
je     1194 <ChangerStatutBouton+0x54>
mov    -0x10(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11df <ChangerStatutBouton+0x9f>
cmpl   $0x1,-0xc(%rbp)
jne    11ae <ChangerStatutBouton+0x6e>
mov    -0x8(%rbp),%edi
call   1040 <ActiverRelai@plt>
mov    %eax,-0x10(%rbp)
jmp    11d9 <ChangerStatutBouton+0x99>
cmpl   $0x0,-0xc(%rbp)
jne    11c8 <ChangerStatutBouton+0x88>
mov    -0x8(%rbp),%edi
call   1030 <DesactiverRelai@plt>
mov    %eax,-0x10(%rbp)
jmp    11d4 <ChangerStatutBouton+0x94>
movl   $0x196,-0x4(%rbp)
jmp    11df <ChangerStatutBouton+0x9f>
jmp    11d9 <ChangerStatutBouton+0x99>
mov    -0x10(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ChangerStatutBouton>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %edi,%ebx
call   1050 <IdentifiantBoutonPlosible@plt>
cmp    $0xc8,%eax
jne    117c <ChangerStatutBouton+0x3c>
mov    %ebp,%edi
call   1060 <StatutBoutonPlosible@plt>
cmp    $0xc8,%eax
jne    117c <ChangerStatutBouton+0x3c>
test   %ebp,%ebp
je     1183 <ChangerStatutBouton+0x43>
mov    $0x196,%eax
cmp    $0x1,%ebp
jne    117c <ChangerStatutBouton+0x3c>
mov    %ebx,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <ActiverRelai@plt>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    %ebx,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <DesactiverRelai@plt>

LLVM IR (-O0):
define i32 @ChangerStatutBouton(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%7 = load i32, i32* %4
%8 = call i32 @IdentifiantBoutonPlosible(i32 %7)
store i32 %8, i32* %6
%9 = load i32, i32* %6
%10 = icmp ne i32 %9, 200
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = load i32, i32* %6
store i32 %12, i32* %3
br label %36
13: ; preds = %2
%14 = load i32, i32* %5
%15 = call i32 @StatutBoutonPlosible(i32 %14)
store i32 %15, i32* %6
%16 = load i32, i32* %6
%17 = icmp ne i32 %16, 200
br i1 %17, label %18, label %20
18: ; preds = %13
%19 = load i32, i32* %6
store i32 %19, i32* %3
br label %36
20: ; preds = %13
%21 = load i32, i32* %5
%22 = icmp eq i32 %21, 1
br i1 %22, label %23, label %26
23: ; preds = %20
%24 = load i32, i32* %4
%25 = call i32 @ActiverRelai(i32 %24)
store i32 %25, i32* %6
br label %34
26: ; preds = %20
%27 = load i32, i32* %5
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %32
29: ; preds = %26
%30 = load i32, i32* %4
%31 = call i32 @DesactiverRelai(i32 %30)
store i32 %31, i32* %6
br label %33
32: ; preds = %26
store i32 406, i32* %3
br label %36
33: ; preds = %29
br label %34
34: ; preds = %33, %23
%35 = load i32, i32* %6
store i32 %35, i32* %3
br label %36
36: ; preds = %34, %32, %18, %11
%37 = load i32, i32* %3
ret i32 %37
}

LLVM IR (-O2):
define i32 @ChangerStatutBouton(i32 %0, i32 %1) {
%3 = tail call i32 @IdentifiantBoutonPlosible(i32 %0)
%4 = icmp eq i32 %3, 200
br i1 %4, label %5, label %13
5: ; preds = %2
%6 = tail call i32 @StatutBoutonPlosible(i32 %1)
%7 = icmp eq i32 %6, 200
br i1 %7, label %8, label %13
8: ; preds = %5
switch i32 %1, label %13 [
i32 1, label %9
i32 0, label %11
]
9: ; preds = %8
%10 = tail call i32 @ActiverRelai(i32 %0)
br label %13
11: ; preds = %8
%12 = tail call i32 @DesactiverRelai(i32 %0)
br label %13
13: ; preds = %9, %11, %8, %5, %2
%14 = phi i32 [ %3, %2 ], [ %6, %5 ], [ 406, %8 ], [ %10, %9 ], [ %12, %11 ]
ret i32 %14
}