#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*/ next_msg_char;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fileno(int /*<<< orphan*/ *);
int /*<<< orphan*/ fsync(int /*<<< orphan*/);
int /*<<< orphan*/ fwrite(unsigned char *, int, int, int /*<<< orphan*/ *);
unsigned char next_letter();
int rand();
int /*<<< orphan*/ *stdout;
int /*<<< orphan*/ system(char *);
void winno_msg(int difficulty, unsigned char *message) {
  FILE *output = stdout;
  unsigned char next_msg_char = 0;
  unsigned char next_chaff = 0;
  int ix = 0;
  next_msg_char = message[ix];
  while (next_msg_char != 0) {
    if ((rand() % (difficulty + 1)) != 0) {
      next_chaff = next_letter();
      ++ix;
    } else {
      fwrite(&next_msg_char, sizeof(next_msg_char), 1, output);
      ++ix;
      next_msg_char = message[ix];
    }
  }
  fsync(fileno(output));
  system("sync; sync;");
  return;
}


x86 assembly (clang, -O0):
<winno_msg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e6a(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
movb   $0x0,-0x19(%rbp)
movb   $0x0,-0x1a(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x19(%rbp)
movzbl -0x19(%rbp),%eax
cmp    $0x0,%eax
je     1208 <winno_msg+0xa8>
mov    $0x0,%al
call   1080 <rand@plt>
mov    -0x4(%rbp),%ecx
add    $0x1,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     11d8 <winno_msg+0x78>
mov    $0x0,%al
call   1030 <next_letter@plt>
mov    %al,-0x1a(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1203 <winno_msg+0xa3>
mov    -0x18(%rbp),%rcx
lea    -0x19(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1070 <fwrite@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x19(%rbp)
jmp    119a <winno_msg+0x3a>
mov    -0x18(%rbp),%rdi
call   1050 <fileno@plt>
mov    %eax,%edi
call   1060 <fsync@plt>
lea    0xde1(%rip),%rdi
call   1040 <system@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<winno_msg>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    0x2e71(%rip),%rax
mov    (%rax),%r15
mov    (%rsi),%bl
test   %bl,%bl
je     11c9 <winno_msg+0x69>
mov    %rsi,%r14
mov    %edi,%r12d
add    $0x1,%r12d
xor    %ebp,%ebp
jmp    11ac <winno_msg+0x4c>
cs nopw 0x0(%rax,%rax,1)
movsbl %bl,%edi
mov    %r15,%rsi
call   1050 <fputc@plt>
movslq %ebp,%rbp
movzbl 0x1(%r14,%rbp,1),%ebx
add    $0x1,%rbp
test   %bl,%bl
je     11c9 <winno_msg+0x69>
xor    %eax,%eax
call   1080 <rand@plt>
cltd
idiv   %r12d
test   %edx,%edx
je     1190 <winno_msg+0x30>
xor    %eax,%eax
call   1030 <next_letter@plt>
add    $0x1,%ebp
test   %bl,%bl
jne    11ac <winno_msg+0x4c>
mov    %r15,%rdi
call   1060 <fileno@plt>
mov    %eax,%edi
call   1070 <fsync@plt>
lea    0xe21(%rip),%rdi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <system@plt>

LLVM IR (-O0):
@stdout = global i32* null
@.str = [12 x i8] c"sync; sync;\00"
define void @winno_msg(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i8
%7 = alloca i8
%8 = alloca i32
store i32 %0, i32* %3
store i8* %1, i8** %4
%9 = load i32*, i32** @stdout
store i32* %9, i32** %5
store i8 0, i8* %6
store i8 0, i8* %7
store i32 0, i32* %8
%10 = load i8*, i8** %4
%11 = load i32, i32* %8
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i8, i8* %10, i64 %12
%14 = load i8, i8* %13
store i8 %14, i8* %6
br label %15
15: ; preds = %39, %2
%16 = load i8, i8* %6
%17 = zext i8 %16 to i32
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %40
19: ; preds = %15
%20 = call i32 (...) @rand()
%21 = load i32, i32* %3
%22 = add nsw i32 %21, 1
%23 = srem i32 %20, %22
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %29
25: ; preds = %19
%26 = call zeroext i8 (...) @next_letter()
store i8 %26, i8* %7
%27 = load i32, i32* %8
%28 = add nsw i32 %27, 1
store i32 %28, i32* %8
br label %39
29: ; preds = %19
%30 = load i32*, i32** %5
%31 = call i32 @fwrite(i8* %6, i32 1, i32 1, i32* %30)
%32 = load i32, i32* %8
%33 = add nsw i32 %32, 1
store i32 %33, i32* %8
%34 = load i8*, i8** %4
%35 = load i32, i32* %8
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8, i8* %34, i64 %36
%38 = load i8, i8* %37
store i8 %38, i8* %6
br label %39
39: ; preds = %29, %25
br label %15
40: ; preds = %15
%41 = load i32*, i32** %5
%42 = call i32 @fileno(i32* %41)
%43 = call i32 @fsync(i32 %42)
%44 = call i32 @system(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@stdout = global i32* null
@.str = [12 x i8] c"sync; sync;\00"
define void @winno_msg(i32 %0, i8* nocapture %1) {
%3 = load i32*, i32** @stdout
%4 = load i8, i8* %1
%5 = icmp eq i8 %4, 0
br i1 %5, label %28, label %6
6: ; preds = %2
%7 = add nsw i32 %0, 1
br label %8
8: ; preds = %6, %24
%9 = phi i32 [ 0, %6 ], [ %26, %24 ]
%10 = phi i8 [ %4, %6 ], [ %25, %24 ]
%11 = tail call i32 (...) @rand()
%12 = srem i32 %11, %7
%13 = icmp eq i32 %12, 0
br i1 %13, label %17, label %14
14: ; preds = %8
%15 = tail call zeroext i8 (...) @next_letter()
%16 = add nsw i32 %9, 1
br label %24
17: ; preds = %8
%18 = sext i8 %10 to i32
%19 = tail call i32 @fputc(i32 %18, i32* %3)
%20 = add nsw i32 %9, 1
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %1, i64 %21
%23 = load i8, i8* %22
br label %24
24: ; preds = %17, %14
%25 = phi i8 [ %23, %17 ], [ %10, %14 ]
%26 = phi i32 [ %20, %17 ], [ %16, %14 ]
%27 = icmp eq i8 %25, 0
br i1 %27, label %28, label %8
28: ; preds = %24, %2
%29 = tail call i32 @fileno(i32* %3)
%30 = tail call i32 @fsync(i32 %29)
%31 = tail call i32 @system(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
ret void
}