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

/* Variables and functions */
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ unlink(char *);
int /*<<< orphan*/ waitpid(int /*<<< orphan*/, int *, int /*<<< orphan*/);
int write(int, char *, int);
void test_success(char *fifo_name, int fd, pid_t odp_app) {
  int status;
  int nb_char;
  char result = 'S';
  nb_char = write(fd, &result, sizeof(char));
  close(fd);
  waitpid(odp_app, &status, 0);
  if (nb_char != 1)
    status = 1;
  unlink(fifo_name);
  exit(status);
}


x86 assembly (clang, -O0):
<test_success>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movb   $0x53,-0x19(%rbp)
mov    -0xc(%rbp),%edi
lea    -0x19(%rbp),%rsi
mov    $0x1,%edx
call   1040 <write@plt>
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%edi
call   1050 <close@plt>
mov    -0x10(%rbp),%edi
lea    -0x14(%rbp),%rsi
xor    %edx,%edx
call   1060 <waitpid@plt>
cmpl   $0x1,-0x18(%rbp)
je     11a1 <test_success+0x51>
movl   $0x1,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <unlink@plt>
mov    -0x14(%rbp),%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<test_success>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r15d
mov    %esi,%ebx
mov    %rdi,%r14
movb   $0x53,0x3(%rsp)
lea    0x3(%rsp),%rsi
mov    %ebx,%edi
mov    $0x1,%edx
call   1040 <write@plt>
mov    %eax,%ebp
mov    %ebx,%edi
call   1050 <close@plt>
lea    0x4(%rsp),%rsi
mov    %r15d,%edi
xor    %edx,%edx
call   1060 <waitpid@plt>
cmp    $0x1,%ebp
je     119a <test_success+0x4a>
movl   $0x1,0x4(%rsp)
mov    %r14,%rdi
call   1030 <unlink@plt>
mov    0x4(%rsp),%edi
call   1070 <exit@plt>

LLVM IR (-O0):
define void @test_success(i8* %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
store i8 83, i8* %9
%10 = load i32, i32* %5
%11 = call i32 @write(i32 %10, i8* %9, i32 1)
store i32 %11, i32* %8
%12 = load i32, i32* %5
%13 = call i32 @close(i32 %12)
%14 = load i32, i32* %6
%15 = call i32 @waitpid(i32 %14, i32* %7, i32 0)
%16 = load i32, i32* %8
%17 = icmp ne i32 %16, 1
br i1 %17, label %18, label %19
18: ; preds = %3
store i32 1, i32* %7
br label %19
19: ; preds = %18, %3
%20 = load i8*, i8** %4
%21 = call i32 @unlink(i8* %20)
%22 = load i32, i32* %7
%23 = call i32 @exit(i32 %22)
unreachable
}

LLVM IR (-O2):
define void @test_success(i8* nocapture %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8
%6 = bitcast i32* %4 to i8*
store i8 83, i8* %5
%7 = call i32 @write(i32 %1, i8* %5, i32 1)
%8 = tail call i32 @close(i32 %1)
%9 = call i32 @waitpid(i32 %2, i32* %4, i32 0)
%10 = icmp eq i32 %7, 1
br i1 %10, label %12, label %11
11: ; preds = %3
store i32 1, i32* %4
br label %12
12: ; preds = %11, %3
%13 = call i32 @unlink(i8* %0)
%14 = load i32, i32* %4
%15 = call i32 @exit(i32 %14)
unreachable
}