#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*/ sprintf(char *, char *);
int strlen(char *);
char *string_ScreenEncodings(unsigned long flags) {
  static int si = 0;
  static char buf[5][80];
  char *bp, *cp;
  cp = bp = buf[si++];
  si %= 5;
  if (flags & 0x00000001L) {
    sprintf(cp, "Default Screen");
  } else {
    sprintf(cp, "No Default Screen");
  }
  cp = cp + strlen(cp);
  if (flags & 0x00000002L) {
    sprintf(cp, ", Lines Per Inch");
  } else {
    sprintf(cp, ", Lines Per cm");
  }
  cp = cp + strlen(cp);
  return bp;
}


x86 assembly (clang, -O0):
<string_ScreenEncodings>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2f0e(%rip),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,0x2f03(%rip)
movslq %eax,%rcx
lea    0x2f09(%rip),%rax
imul   $0x50,%rcx,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    %rax,-0x18(%rbp)
mov    0x2ee4(%rip),%eax
mov    $0x5,%ecx
cltd
idiv   %ecx
mov    %edx,0x2ed6(%rip)
mov    -0x8(%rbp),%rax
and    $0x1,%rax
cmp    $0x0,%rax
je     1191 <string_ScreenEncodings+0x71>
mov    -0x18(%rbp),%rdi
lea    0xe7c(%rip),%rsi
call   1040 <sprintf@plt>
jmp    11a1 <string_ScreenEncodings+0x81>
mov    -0x18(%rbp),%rdi
lea    0xe64(%rip),%rsi
call   1040 <sprintf@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
and    $0x2,%rax
cmp    $0x0,%rax
je     11e9 <string_ScreenEncodings+0xc9>
mov    -0x18(%rbp),%rdi
lea    0xe33(%rip),%rsi
call   1040 <sprintf@plt>
jmp    11f9 <string_ScreenEncodings+0xd9>
mov    -0x18(%rbp),%rdi
lea    0xe2f(%rip),%rsi
call   1040 <sprintf@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<string_ScreenEncodings>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    0x2f23(%rip),%eax
lea    0x1(%rax),%ecx
lea    (%rax,%rax,4),%rax
shl    $0x4,%rax
lea    0x2f21(%rip),%rbx
add    %rax,%rbx
movslq %ecx,%rax
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x21,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%eax
mov    %eax,0x2eec(%rip)
test   $0x1,%r14b
jne    116c <string_ScreenEncodings+0x5c>
movups 0xe9f(%rip),%xmm0
movups %xmm0,(%rbx)
movw   $0x6e,0x10(%rbx)
jmp    1187 <string_ScreenEncodings+0x77>
movabs $0x6e656572635320,%rax
mov    %rax,0x7(%rbx)
movabs $0x20746c7561666544,%rax
6c 74 20
mov    %rax,(%rbx)
mov    %rbx,%rdi
call   1030 <strlen@plt>
movslq %eax,%rdi
add    %rbx,%rdi
test   $0x2,%r14b
jne    11b8 <string_ScreenEncodings+0xa8>
movabs $0x6d632072655020,%rax
mov    %rax,0x7(%rdi)
movabs $0x2073656e694c202c,%rax
65 73 20
mov    %rax,(%rdi)
jmp    11c6 <string_ScreenEncodings+0xb6>
movups 0xe53(%rip),%xmm0
movups %xmm0,(%rdi)
movb   $0x0,0x10(%rdi)
call   1030 <strlen@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@string_ScreenEncodings.si = internal global i32 0
@string_ScreenEncodings.buf = internal global [5 x [80 x i8]] zeroinitializer
@.str = [15 x i8] c"Default Screen\00"
@.str.1 = [18 x i8] c"No Default Screen\00"
@.str.2 = [17 x i8] c", Lines Per Inch\00"
@.str.3 = [15 x i8] c", Lines Per cm\00"
define i8* @string_ScreenEncodings(i64 %0) {
%2 = alloca i64
%3 = alloca i8*
%4 = alloca i8*
store i64 %0, i64* %2
%5 = load i32, i32* @string_ScreenEncodings.si
%6 = add nsw i32 %5, 1
store i32 %6, i32* @string_ScreenEncodings.si
%7 = sext i32 %5 to i64
%8 = getelementptr inbounds [5 x [80 x i8]], [5 x [80 x i8]]* @string_ScreenEncodings.buf, i64 0, i64 %7
%9 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 0
store i8* %9, i8** %3
store i8* %9, i8** %4
%10 = load i32, i32* @string_ScreenEncodings.si
%11 = srem i32 %10, 5
store i32 %11, i32* @string_ScreenEncodings.si
%12 = load i64, i64* %2
%13 = and i64 %12, 1
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %1
%16 = load i8*, i8** %4
%17 = call i32 @sprintf(i8* %16, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
br label %21
18: ; preds = %1
%19 = load i8*, i8** %4
%20 = call i32 @sprintf(i8* %19, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
br label %21
21: ; preds = %18, %15
%22 = load i8*, i8** %4
%23 = load i8*, i8** %4
%24 = call i32 @strlen(i8* %23)
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %22, i64 %25
store i8* %26, i8** %4
%27 = load i64, i64* %2
%28 = and i64 %27, 2
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %33
30: ; preds = %21
%31 = load i8*, i8** %4
%32 = call i32 @sprintf(i8* %31, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
br label %36
33: ; preds = %21
%34 = load i8*, i8** %4
%35 = call i32 @sprintf(i8* %34, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
br label %36
36: ; preds = %33, %30
%37 = load i8*, i8** %4
%38 = load i8*, i8** %4
%39 = call i32 @strlen(i8* %38)
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8, i8* %37, i64 %40
store i8* %41, i8** %4
%42 = load i8*, i8** %3
ret i8* %42
}

LLVM IR (-O2):
@string_ScreenEncodings.si = internal unnamed_addr global i32 0
@string_ScreenEncodings.buf = internal global [5 x [80 x i8]] zeroinitializer
@.str = [15 x i8] c"Default Screen\00"
@.str.1 = [18 x i8] c"No Default Screen\00"
@.str.2 = [17 x i8] c", Lines Per Inch\00"
@.str.3 = [15 x i8] c", Lines Per cm\00"
define i8* @string_ScreenEncodings(i64 %0) {
%2 = load i32, i32* @string_ScreenEncodings.si
%3 = add nsw i32 %2, 1
%4 = zext i32 %2 to i64
%5 = getelementptr inbounds [5 x [80 x i8]], [5 x [80 x i8]]* @string_ScreenEncodings.buf, i64 0, i64 %4, i64 0
%6 = srem i32 %3, 5
store i32 %6, i32* @string_ScreenEncodings.si
%7 = and i64 %0, 1
%8 = icmp eq i64 %7, 0
br i1 %8, label %10, label %9
9: ; preds = %1
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 16 dereferenceable(15) %5, i8* align 1 dereferenceable(15) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i64 15, i1 false)
br label %11
10: ; preds = %1
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 16 dereferenceable(18) %5, i8* align 1 dereferenceable(18) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i64 18, i1 false)
br label %11
11: ; preds = %10, %9
%12 = tail call i32 @strlen(i8* %5)
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [5 x [80 x i8]], [5 x [80 x i8]]* @string_ScreenEncodings.buf, i64 0, i64 %4, i64 %13
%15 = and i64 %0, 2
%16 = icmp eq i64 %15, 0
br i1 %16, label %18, label %17
17: ; preds = %11
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(17) %14, i8* align 1 dereferenceable(17) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i64 17, i1 false)
br label %19
18: ; preds = %11
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(15) %14, i8* align 1 dereferenceable(15) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i64 15, i1 false)
br label %19
19: ; preds = %18, %17
%20 = tail call i32 @strlen(i8* %14)
ret i8* %5
}