#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 /*<<< orphan*/ error(char *);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ stdout;
void warning(char *msg) {
  static int n_warn = 0;
  fprintf(stdout, "warning: %s.\n", msg);
  n_warn++;
  if (n_warn >= 10) {
    sprintf(msg, "maximum number of warnings exceeded %d", 10);
    error(msg);
  }
  fflush(stdout);
}


x86 assembly (clang, -O0):
<warning>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2e8d(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xea0(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2ed9(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2ed0(%rip)
cmpl   $0xa,0x2ec9(%rip)
jl     119f <warning+0x5f>
mov    -0x8(%rbp),%rdi
lea    0xe82(%rip),%rsi
mov    $0xa,%edx
call   1060 <sprintf@plt>
mov    -0x8(%rbp),%rdi
call   1050 <error@plt>
mov    0x2e3a(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<warning>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    0x2e92(%rip),%r14
mov    (%r14),%edi
lea    0xea8(%rip),%rsi
mov    %rbx,%rdx
call   1030 <fprintf@plt>
mov    0x2ede(%rip),%eax
lea    0x1(%rax),%ecx
mov    %ecx,0x2ed5(%rip)
cmp    $0x9,%eax
jl     1190 <warning+0x50>
lea    0xe93(%rip),%rsi
mov    %rbx,%rdi
mov    $0xa,%edx
call   1060 <sprintf@plt>
mov    %rbx,%rdi
call   1050 <error@plt>
mov    (%r14),%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <fflush@plt>

LLVM IR (-O0):
@warning.n_warn = internal global i32 0
@stdout = global i32 0
@.str = [14 x i8] c"warning: %s.\0A\00"
@.str.1 = [39 x i8] c"maximum number of warnings exceeded %d\00"
define void @warning(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i32, i32* @stdout
%4 = load i8*, i8** %2
%5 = call i32 @fprintf(i32 %3, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %4)
%6 = load i32, i32* @warning.n_warn
%7 = add nsw i32 %6, 1
store i32 %7, i32* @warning.n_warn
%8 = load i32, i32* @warning.n_warn
%9 = icmp sge i32 %8, 10
br i1 %9, label %10, label %15
10: ; preds = %1
%11 = load i8*, i8** %2
%12 = call i32 @sprintf(i8* %11, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0), i32 10)
%13 = load i8*, i8** %2
%14 = call i32 @error(i8* %13)
br label %15
15: ; preds = %10, %1
%16 = load i32, i32* @stdout
%17 = call i32 @fflush(i32 %16)
ret void
}

LLVM IR (-O2):
@warning.n_warn = internal unnamed_addr global i32 0
@stdout = global i32 0
@.str = [14 x i8] c"warning: %s.\0A\00"
@.str.1 = [39 x i8] c"maximum number of warnings exceeded %d\00"
define void @warning(i8* %0) {
%2 = load i32, i32* @stdout
%3 = tail call i32 @fprintf(i32 %2, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %0)
%4 = load i32, i32* @warning.n_warn
%5 = add nsw i32 %4, 1
store i32 %5, i32* @warning.n_warn
%6 = icmp sgt i32 %4, 8
br i1 %6, label %7, label %10
7: ; preds = %1
%8 = tail call i32 @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0), i32 10)
%9 = tail call i32 @error(i8* %0)
br label %10
10: ; preds = %7, %1
%11 = load i32, i32* @stdout
%12 = tail call i32 @fflush(i32 %11)
ret void
}