#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 */
scalar_t__ strcmp(char const *, char *);
char *setlocale(int category, const char *name) {
  if (name != NULL) {
    if (strcmp(name, "C") && strcmp(name, "POSIX") && strcmp(name, ""))
      return NULL;
  }
  return (char *)"C";
}


x86 assembly (clang, -O0):
<setlocale>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0xc(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     118a <setlocale+0x7a>
mov    -0x18(%rbp),%rdi
lea    0xecb(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
je     1185 <setlocale+0x75>
mov    -0x18(%rbp),%rdi
lea    0xeb3(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
je     1185 <setlocale+0x75>
mov    -0x18(%rbp),%rdi
lea    0xe98(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
je     1185 <setlocale+0x75>
movq   $0x0,-0x8(%rbp)
jmp    1195 <setlocale+0x85>
jmp    118a <setlocale+0x7a>
lea    0xe6f(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setlocale>:
push   %rbx
test   %rsi,%rsi
je     1159 <setlocale+0x49>
mov    %rsi,%rbx
lea    0xee0(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1159 <setlocale+0x49>
lea    0xece(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1159 <setlocale+0x49>
lea    0xeb9(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1159 <setlocale+0x49>
xor    %eax,%eax
pop    %rbx
ret
lea    0xea0(%rip),%rax
pop    %rbx
ret

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

LLVM IR (-O2):
@.str = [2 x i8] c"C\00"
@.str.1 = [6 x i8] c"POSIX\00"
@.str.2 = [1 x i8] zeroinitializer
define i8* @setlocale(i32 %0, i8* %1) {
%3 = icmp eq i8* %1, null
br i1 %3, label %13, label %4
4: ; preds = %2
%5 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i64 %5, 0
br i1 %6, label %13, label %7
7: ; preds = %4
%8 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %13, label %10
10: ; preds = %7
%11 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %4, %7, %10, %2
br label %14
14: ; preds = %10, %13
%15 = phi i8* [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), %13 ], [ null, %10 ]
ret i8* %15
}