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

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ execvp(char *, char **);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int fork();
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *);
int /*<<< orphan*/ waitpid(int, int /*<<< orphan*/, int /*<<< orphan*/);
void wmfs_flush(char *buffer, char *screename) {
  char status[0x200];
  pid_t pid;
  pid = fork();
  char *args[] = {"wmfs", "-c", "status", status, NULL};
  sprintf(status, "%s %s", screename, buffer);
  switch (pid) {
  case -1:
    perror("fork");
    break;
  case 0:
    execvp(args[0], args);
    perror("execvp");
    exit(EXIT_FAILURE);
    break;
  default:
    waitpid(pid, 0, 0);
  }
  buffer[0] = '\0';
}


x86 assembly (clang, -O0):
<wmfs_flush>:
push   %rbp
mov    %rsp,%rbp
sub    $0x250,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %eax,%eax
call   1080 <fork@plt>
mov    %eax,-0x214(%rbp)
lea    0xe79(%rip),%rax
mov    %rax,-0x240(%rbp)
lea    0xe70(%rip),%rax
mov    %rax,-0x238(%rbp)
lea    0xe65(%rip),%rax
mov    %rax,-0x230(%rbp)
lea    -0x210(%rbp),%rdi
mov    %rdi,-0x228(%rbp)
movq   $0x0,-0x220(%rbp)
mov    -0x10(%rbp),%rdx
mov    -0x8(%rbp),%rcx
lea    0xe3d(%rip),%rsi
call   1060 <sprintf@plt>
mov    -0x214(%rbp),%eax
mov    %eax,-0x244(%rbp)
sub    $0xffffffff,%eax
je     1204 <wmfs_flush+0xa4>
jmp    11f1 <wmfs_flush+0x91>
mov    -0x244(%rbp),%eax
test   %eax,%eax
je     1215 <wmfs_flush+0xb5>
jmp    1242 <wmfs_flush+0xe2>
lea    0xe0a(%rip),%rdi
call   1040 <perror@plt>
jmp    1251 <wmfs_flush+0xf1>
mov    -0x240(%rbp),%rdi
lea    -0x240(%rbp),%rsi
call   1050 <execvp@plt>
lea    0xdeb(%rip),%rdi
call   1040 <perror@plt>
mov    0x2da5(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    -0x214(%rbp),%edi
xor    %edx,%edx
mov    %edx,%esi
call   1030 <waitpid@plt>
mov    -0x8(%rbp),%rax
movb   $0x0,(%rax)
add    $0x250,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wmfs_flush>:
push   %rbp
push   %r14
push   %rbx
sub    $0x230,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
xor    %eax,%eax
call   1080 <fork@plt>
mov    %eax,%ebp
lea    0xe7f(%rip),%rax
mov    %rax,(%rsp)
lea    0xe79(%rip),%rax
mov    %rax,0x8(%rsp)
lea    0xe70(%rip),%rax
mov    %rax,0x10(%rsp)
lea    0x30(%rsp),%rdi
mov    %rdi,0x18(%rsp)
movq   $0x0,0x20(%rsp)
lea    0xe58(%rip),%rsi
mov    %rbx,%rdx
mov    %r14,%rcx
call   1060 <sprintf@plt>
cmp    $0xffffffff,%ebp
je     11e6 <wmfs_flush+0x86>
test   %ebp,%ebp
je     11f4 <wmfs_flush+0x94>
mov    %ebp,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1030 <waitpid@plt>
movb   $0x0,(%r14)
add    $0x230,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xe28(%rip),%rdi
call   1040 <perror@plt>
jmp    11d6 <wmfs_flush+0x76>
lea    0xe05(%rip),%rdi
mov    %rsp,%rsi
call   1050 <execvp@plt>
lea    0xe10(%rip),%rdi
call   1040 <perror@plt>
mov    0x2dca(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"wmfs\00"
@.str.1 = [3 x i8] c"-c\00"
@.str.2 = [7 x i8] c"status\00"
@.str.3 = [6 x i8] c"%s %s\00"
@.str.4 = [5 x i8] c"fork\00"
@.str.5 = [7 x i8] c"execvp\00"
@EXIT_FAILURE = global i32 0
define void @wmfs_flush(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [512 x i8]
%6 = alloca i32
%7 = alloca [5 x i8*]
store i8* %0, i8** %3
store i8* %1, i8** %4
%8 = call i32 (...) @fork()
store i32 %8, i32* %6
%9 = getelementptr inbounds [5 x i8*], [5 x i8*]* %7, i64 0, i64 0
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %9
%10 = getelementptr inbounds i8*, i8** %9, i64 1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8** %10
%11 = getelementptr inbounds i8*, i8** %10, i64 1
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8** %11
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
store i8* %13, i8** %12
%14 = getelementptr inbounds i8*, i8** %12, i64 1
store i8* null, i8** %14
%15 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%16 = load i8*, i8** %4
%17 = load i8*, i8** %3
%18 = call i32 @sprintf(i8* %15, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* %16, i8* %17)
%19 = load i32, i32* %6
switch i32 %19, label %30 [
i32 -1, label %20
i32 0, label %22
]
20: ; preds = %2
%21 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
br label %33
22: ; preds = %2
%23 = getelementptr inbounds [5 x i8*], [5 x i8*]* %7, i64 0, i64 0
%24 = load i8*, i8** %23
%25 = getelementptr inbounds [5 x i8*], [5 x i8*]* %7, i64 0, i64 0
%26 = call i32 @execvp(i8* %24, i8** %25)
%27 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
%28 = load i32, i32* @EXIT_FAILURE
%29 = call i32 @exit(i32 %28)
unreachable
30: ; preds = %2
%31 = load i32, i32* %6
%32 = call i32 @waitpid(i32 %31, i32 0, i32 0)
br label %33
33: ; preds = %30, %20
%34 = load i8*, i8** %3
%35 = getelementptr inbounds i8, i8* %34, i64 0
store i8 0, i8* %35
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"wmfs\00"
@.str.1 = [3 x i8] c"-c\00"
@.str.2 = [7 x i8] c"status\00"
@.str.3 = [6 x i8] c"%s %s\00"
@.str.4 = [5 x i8] c"fork\00"
@.str.5 = [7 x i8] c"execvp\00"
@EXIT_FAILURE = global i32 0
define void @wmfs_flush(i8* %0, i8* %1) {
%3 = alloca [512 x i8]
%4 = alloca [5 x i8*]
%5 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%6 = tail call i32 (...) @fork()
%7 = bitcast [5 x i8*]* %4 to i8*
%8 = getelementptr inbounds [5 x i8*], [5 x i8*]* %4, i64 0, i64 0
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %8
%9 = getelementptr inbounds [5 x i8*], [5 x i8*]* %4, i64 0, i64 1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8** %9
%10 = getelementptr inbounds [5 x i8*], [5 x i8*]* %4, i64 0, i64 2
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8** %10
%11 = getelementptr inbounds [5 x i8*], [5 x i8*]* %4, i64 0, i64 3
store i8* %5, i8** %11
%12 = getelementptr inbounds [5 x i8*], [5 x i8*]* %4, i64 0, i64 4
store i8* null, i8** %12
%13 = call i32 @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* %1, i8* %0)
switch i32 %6, label %21 [
i32 -1, label %14
i32 0, label %16
]
14: ; preds = %2
%15 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
br label %23
16: ; preds = %2
%17 = call i32 @execvp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %8)
%18 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
%19 = load i32, i32* @EXIT_FAILURE
%20 = call i32 @exit(i32 %19)
unreachable
21: ; preds = %2
%22 = call i32 @waitpid(i32 %6, i32 0, i32 0)
br label %23
23: ; preds = %21, %14
store i8 0, i8* %0
ret void
}