#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 */
struct lconv {
  scalar_t__ thousands_sep;
};

/* Variables and functions */
scalar_t__ k_strlen(scalar_t__);
int _get_quote_seps(int value, int flags, struct lconv *lc) {
  int ret;
  if (!(flags & (1 << 7)))
    ret = 0;
  else {
    ret = (value - ((value % 3) == 0 ? 1 : 0)) / 3;
    if (lc->thousands_sep)
      ret *= (int)k_strlen(lc->thousands_sep);
  }
  return ret;
}


x86 assembly (clang, -O0):
<_get_quote_seps>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    -0x8(%rbp),%eax
and    $0x80,%eax
cmp    $0x0,%eax
jne    113f <_get_quote_seps+0x2f>
movl   $0x0,-0x14(%rbp)
jmp    1195 <_get_quote_seps+0x85>
mov    -0x4(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    -0x18(%rbp),%eax
mov    %edx,%esi
xor    %ecx,%ecx
mov    $0x1,%edx
cmp    $0x0,%esi
cmove  %edx,%ecx
sub    %ecx,%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
je     1190 <_get_quote_seps+0x80>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1030 <k_strlen@plt>
imul   -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    1195 <_get_quote_seps+0x85>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_get_quote_seps>:
push   %rbx
xor    %ebx,%ebx
test   $0x80,%sil
je     1153 <_get_quote_seps+0x43>
imul   $0xaaaaaaab,%edi,%eax
add    $0x2aaaaaaa,%eax
cmp    $0x55555555,%eax
sbb    $0x0,%edi
movslq %edi,%rax
imul   $0x55555556,%rax,%rbx
mov    %rbx,%rax
shr    $0x3f,%rax
shr    $0x20,%rbx
add    %eax,%ebx
mov    (%rdx),%rdi
test   %rdi,%rdi
je     1153 <_get_quote_seps+0x43>
call   1030 <k_strlen@plt>
imul   %eax,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
%struct.lconv = type { i64 }
define i32 @_get_quote_seps(i32 %0, i32 %1, %struct.lconv* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca %struct.lconv*
%7 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store %struct.lconv* %2, %struct.lconv** %6
%8 = load i32, i32* %5
%9 = and i32 %8, 128
%10 = icmp ne i32 %9, 0
br i1 %10, label %12, label %11
11: ; preds = %3
store i32 0, i32* %7
br label %34
12: ; preds = %3
%13 = load i32, i32* %4
%14 = load i32, i32* %4
%15 = srem i32 %14, 3
%16 = icmp eq i32 %15, 0
%17 = zext i1 %16 to i64
%18 = select i1 %16, i32 1, i32 0
%19 = sub nsw i32 %13, %18
%20 = sdiv i32 %19, 3
store i32 %20, i32* %7
%21 = load %struct.lconv*, %struct.lconv** %6
%22 = getelementptr inbounds %struct.lconv, %struct.lconv* %21, i32 0, i32 0
%23 = load i64, i64* %22
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %33
25: ; preds = %12
%26 = load %struct.lconv*, %struct.lconv** %6
%27 = getelementptr inbounds %struct.lconv, %struct.lconv* %26, i32 0, i32 0
%28 = load i64, i64* %27
%29 = call i64 @k_strlen(i64 %28)
%30 = trunc i64 %29 to i32
%31 = load i32, i32* %7
%32 = mul nsw i32 %31, %30
store i32 %32, i32* %7
br label %33
33: ; preds = %25, %12
br label %34
34: ; preds = %33, %11
%35 = load i32, i32* %7
ret i32 %35
}

LLVM IR (-O2):
%struct.lconv = type { i64 }
define i32 @_get_quote_seps(i32 %0, i32 %1, %struct.lconv* nocapture %2) {
%4 = and i32 %1, 128
%5 = icmp eq i32 %4, 0
br i1 %5, label %19, label %6
6: ; preds = %3
%7 = srem i32 %0, 3
%8 = icmp eq i32 %7, 0
%9 = sext i1 %8 to i32
%10 = add i32 %9, %0
%11 = sdiv i32 %10, 3
%12 = getelementptr inbounds %struct.lconv, %struct.lconv* %2, i64 0, i32 0
%13 = load i64, i64* %12
%14 = icmp eq i64 %13, 0
br i1 %14, label %19, label %15
15: ; preds = %6
%16 = tail call i64 @k_strlen(i64 %13)
%17 = trunc i64 %16 to i32
%18 = mul nsw i32 %11, %17
br label %19
19: ; preds = %3, %6, %15
%20 = phi i32 [ %18, %15 ], [ %11, %6 ], [ 0, %3 ]
ret i32 %20
}