#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*/ LC_ALL;
int /*<<< orphan*/ puts(char *);
int run_test(char *);
int /*<<< orphan*/ *setlocale(int /*<<< orphan*/, char *);
int do_test(void) {
  int result;
  if (setlocale(LC_ALL, "C") == NULL) {
    puts("cannot set C locale");
    result = 1;
  } else
    result = run_test("C");
  if (setlocale(LC_ALL, "POSIX") == NULL) {
    puts("cannot set POSIX locale");
    result = 1;
  } else
    result |= run_test("POSIX");
  return result;
}


x86 assembly (clang, -O0):
<do_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2ea1(%rip),%rax
mov    (%rax),%edi
lea    0xeb8(%rip),%rsi
call   1050 <setlocale@plt>
cmp    $0x0,%rax
jne    116f <do_test+0x3f>
lea    0xea4(%rip),%rdi
call   1030 <puts@plt>
movl   $0x1,-0x4(%rbp)
jmp    117e <do_test+0x4e>
lea    0xe8a(%rip),%rdi
call   1040 <run_test@plt>
mov    %eax,-0x4(%rbp)
mov    0x2e5b(%rip),%rax
mov    (%rax),%edi
lea    0xe88(%rip),%rsi
call   1050 <setlocale@plt>
cmp    $0x0,%rax
jne    11b5 <do_test+0x85>
lea    0xe78(%rip),%rdi
call   1030 <puts@plt>
movl   $0x1,-0x4(%rbp)
jmp    11c7 <do_test+0x97>
lea    0xe5a(%rip),%rdi
call   1040 <run_test@plt>
or     -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_test>:
push   %r14
push   %rbx
push   %rax
mov    0x2ea5(%rip),%r14
mov    (%r14),%edi
lea    0xebb(%rip),%rsi
call   1050 <setlocale@plt>
test   %rax,%rax
je     115f <do_test+0x2f>
lea    0xeaa(%rip),%rdi
call   1040 <run_test@plt>
mov    %eax,%ebx
jmp    1170 <do_test+0x40>
lea    0xe9c(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebx
mov    (%r14),%edi
lea    0xe9c(%rip),%rsi
call   1050 <setlocale@plt>
test   %rax,%rax
je     1194 <do_test+0x64>
lea    0xe8b(%rip),%rdi
call   1040 <run_test@plt>
or     %ebx,%eax
jmp    11a5 <do_test+0x75>
lea    0xe81(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@LC_ALL = global i32 0
@.str = [2 x i8] c"C\00"
@.str.1 = [20 x i8] c"cannot set C locale\00"
@.str.2 = [6 x i8] c"POSIX\00"
@.str.3 = [24 x i8] c"cannot set POSIX locale\00"
define i32 @do_test() {
%1 = alloca i32
%2 = load i32, i32* @LC_ALL
%3 = call i32* @setlocale(i32 %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %5, label %7
5: ; preds = %0
%6 = call i32 @puts(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %1
br label %9
7: ; preds = %0
%8 = call i32 @run_test(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32 %8, i32* %1
br label %9
9: ; preds = %7, %5
%10 = load i32, i32* @LC_ALL
%11 = call i32* @setlocale(i32 %10, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %15
13: ; preds = %9
%14 = call i32 @puts(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %1
br label %19
15: ; preds = %9
%16 = call i32 @run_test(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%17 = load i32, i32* %1
%18 = or i32 %17, %16
store i32 %18, i32* %1
br label %19
19: ; preds = %15, %13
%20 = load i32, i32* %1
ret i32 %20
}

LLVM IR (-O2):
@LC_ALL = global i32 0
@.str = [2 x i8] c"C\00"
@.str.1 = [20 x i8] c"cannot set C locale\00"
@.str.2 = [6 x i8] c"POSIX\00"
@.str.3 = [24 x i8] c"cannot set POSIX locale\00"
define i32 @do_test() {
%1 = load i32, i32* @LC_ALL
%2 = tail call i32* @setlocale(i32 %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i32* %2, null
br i1 %3, label %4, label %6
4: ; preds = %0
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
br label %8
6: ; preds = %0
%7 = tail call i32 @run_test(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %8
8: ; preds = %6, %4
%9 = phi i32 [ 1, %4 ], [ %7, %6 ]
%10 = load i32, i32* @LC_ALL
%11 = tail call i32* @setlocale(i32 %10, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %15
13: ; preds = %8
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
br label %18
15: ; preds = %8
%16 = tail call i32 @run_test(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%17 = or i32 %16, %9
br label %18
18: ; preds = %15, %13
%19 = phi i32 [ 1, %13 ], [ %17, %15 ]
ret i32 %19
}