#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*/ perror(char *);
scalar_t__ setenv(char *, char *, int);
scalar_t__ snprintf(char *, int, char *, int);
void set_env_coords(int x, int y) {
  char mousex[200];
  char mousey[200];
  if (snprintf(mousex, 200, "%d", x) < 0) {
    perror("snprintf");
    return;
  }
  if (snprintf(mousey, 200, "%d", y) < 0) {
    perror("snprintf");
    return;
  }
  do {
    if (setenv("MOUSE_X", mousex, 1) < 0) {
      perror("setenv");
    }
  } while (0);
  do {
    if (setenv("MOUSE_Y", mousey, 1) < 0) {
      perror("setenv");
    }
  } while (0);
}


x86 assembly (clang, -O0):
<set_env_coords>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1a0,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
lea    -0xd0(%rbp),%rdi
mov    -0x4(%rbp),%ecx
mov    $0xc8,%esi
lea    0xea9(%rip),%rdx
call   1040 <snprintf@plt>
cmp    $0x0,%rax
jge    1177 <set_env_coords+0x47>
lea    0xe96(%rip),%rdi
call   1050 <perror@plt>
jmp    121d <set_env_coords+0xed>
lea    -0x1a0(%rbp),%rdi
mov    -0x8(%rbp),%ecx
mov    $0xc8,%esi
lea    0xe73(%rip),%rdx
call   1040 <snprintf@plt>
cmp    $0x0,%rax
jge    11ad <set_env_coords+0x7d>
lea    0xe60(%rip),%rdi
call   1050 <perror@plt>
jmp    121d <set_env_coords+0xed>
jmp    11b2 <set_env_coords+0x82>
lea    -0xd0(%rbp),%rsi
lea    0xe4c(%rip),%rdi
mov    $0x1,%edx
call   1030 <setenv@plt>
cmp    $0x0,%rax
jge    11e0 <set_env_coords+0xb0>
lea    0xe39(%rip),%rdi
call   1050 <perror@plt>
jmp    11e5 <set_env_coords+0xb5>
jmp    11ea <set_env_coords+0xba>
lea    -0x1a0(%rbp),%rsi
lea    0xe23(%rip),%rdi
mov    $0x1,%edx
call   1030 <setenv@plt>
cmp    $0x0,%rax
jge    1218 <set_env_coords+0xe8>
lea    0xe01(%rip),%rdi
call   1050 <perror@plt>
jmp    121d <set_env_coords+0xed>
add    $0x1a0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_env_coords>:
push   %rbp
push   %rbx
sub    $0x198,%rsp
mov    %esi,%ebp
mov    %edi,%ecx
lea    0xebc(%rip),%rdx
lea    0xd0(%rsp),%rdi
mov    $0xc8,%esi
call   1040 <snprintf@plt>
lea    0xea6(%rip),%rbx
test   %rax,%rax
js     11d3 <set_env_coords+0xa3>
lea    0xe97(%rip),%rdx
mov    %rsp,%rdi
mov    $0xc8,%esi
mov    %ebp,%ecx
call   1040 <snprintf@plt>
test   %rax,%rax
js     11d3 <set_env_coords+0xa3>
lea    0xe88(%rip),%rdi
lea    0xd0(%rsp),%rsi
mov    $0x1,%edx
call   1030 <setenv@plt>
test   %rax,%rax
js     11be <set_env_coords+0x8e>
lea    0xe79(%rip),%rdi
mov    %rsp,%rsi
mov    $0x1,%edx
call   1030 <setenv@plt>
test   %rax,%rax
js     11cc <set_env_coords+0x9c>
add    $0x198,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xe4f(%rip),%rdi
call   1050 <perror@plt>
jmp    119b <set_env_coords+0x6b>
lea    0xe41(%rip),%rbx
mov    %rbx,%rdi
call   1050 <perror@plt>
jmp    11b4 <set_env_coords+0x84>

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [9 x i8] c"snprintf\00"
@.str.2 = [8 x i8] c"MOUSE_X\00"
@.str.3 = [7 x i8] c"setenv\00"
@.str.4 = [8 x i8] c"MOUSE_Y\00"
define void @set_env_coords(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca [200 x i8]
%6 = alloca [200 x i8]
store i32 %0, i32* %3
store i32 %1, i32* %4
%7 = getelementptr inbounds [200 x i8], [200 x i8]* %5, i64 0, i64 0
%8 = load i32, i32* %3
%9 = call i64 @snprintf(i8* %7, i32 200, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = icmp slt i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
br label %36
13: ; preds = %2
%14 = getelementptr inbounds [200 x i8], [200 x i8]* %6, i64 0, i64 0
%15 = load i32, i32* %4
%16 = call i64 @snprintf(i8* %14, i32 200, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = icmp slt i64 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %13
%19 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
br label %36
20: ; preds = %13
br label %21
21: ; preds = %20
%22 = getelementptr inbounds [200 x i8], [200 x i8]* %5, i64 0, i64 0
%23 = call i64 @setenv(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* %22, i32 1)
%24 = icmp slt i64 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %21
%26 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
br label %27
27: ; preds = %25, %21
br label %28
28: ; preds = %27
br label %29
29: ; preds = %28
%30 = getelementptr inbounds [200 x i8], [200 x i8]* %6, i64 0, i64 0
%31 = call i64 @setenv(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* %30, i32 1)
%32 = icmp slt i64 %31, 0
br i1 %32, label %33, label %35
33: ; preds = %29
%34 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
br label %35
35: ; preds = %33, %29
br label %36
36: ; preds = %11, %18, %35
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [9 x i8] c"snprintf\00"
@.str.2 = [8 x i8] c"MOUSE_X\00"
@.str.3 = [7 x i8] c"setenv\00"
@.str.4 = [8 x i8] c"MOUSE_Y\00"
define void @set_env_coords(i32 %0, i32 %1) {
%3 = alloca [200 x i8]
%4 = alloca [200 x i8]
%5 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [200 x i8], [200 x i8]* %4, i64 0, i64 0
%7 = call i64 @snprintf(i8* %5, i32 200, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %0)
%8 = icmp slt i64 %7, 0
br i1 %8, label %20, label %9
9: ; preds = %2
%10 = call i64 @snprintf(i8* %6, i32 200, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %1)
%11 = icmp slt i64 %10, 0
br i1 %11, label %20, label %12
12: ; preds = %9
%13 = call i64 @setenv(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* %5, i32 1)
%14 = icmp slt i64 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
br label %17
17: ; preds = %12, %15
%18 = call i64 @setenv(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* %6, i32 1)
%19 = icmp slt i64 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %17, %9, %2
%21 = phi i8* [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), %2 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), %9 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), %17 ]
%22 = call i32 @perror(i8* %21)
br label %23
23: ; preds = %20, %17
ret void
}