#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 mat2_2d {
  int dummy;
};

/* Variables and functions */
unsigned int getUsedNumDatMt22d(struct mat2_2d *);
unsigned int getUsedOffsetNumDatMt22d(struct mat2_2d *, unsigned int);
int /*<<< orphan*/ printf(char *, unsigned int const, ...);
int convertIndex2IdSegAndOfSt4Mt22d(struct mat2_2d *obj, const unsigned int id,
                                    unsigned int *indexSegment,
                                    unsigned int *offset) {
  int ret = ((obj != NULL) && (indexSegment != NULL) && (offset != NULL));
  unsigned int index = 0;
  unsigned int num = getUsedNumDatMt22d(obj);
  unsigned int num2 = 0;
  unsigned int tmp1 = id;
  if (ret == 1) {
    ret = 0;
    for (index = 0; index < num; index++) {
      num2 = getUsedOffsetNumDatMt22d(obj, index);
      if (tmp1 < num2) {
        *indexSegment = index;
        *offset = tmp1;
        index = num;
        ret = 1;
      } else {
        tmp1 = tmp1 - num2;
      }
    }
    if (ret == 0) {
      printf("Error(1) in convertIndex2IdSegAndOfSt4Mt22d, the id(%u) "
             "exceed:%u, ln:%d,File:%s\n",
             id, tmp1, 1094,
             "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/Chalearm/MachineLearning-/refs/heads/"
             "master/mProject/library_jui/dataStruct/src/simMat2.c");
    } else {
    }
  } else {
    printf("Error(0) in convertIndex2IdSegAndOfSt4Mt22d, obj:%p, "
           "idSeg:%p,Offset:%p ,ln:%d, file:%s\n",
           obj, indexSegment, offset, 1103,
           "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
           "2022-01-22/02-19-57/repos/Chalearm/MachineLearning-/refs/heads/"
           "master/mProject/library_jui/dataStruct/src/simMat2.c");
  }
  return ret;
}


x86 assembly (clang, -O0):
<convertIndex2IdSegAndOfSt4Mt22d>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x8(%rbp)
mov    %al,-0x35(%rbp)
je     1172 <convertIndex2IdSegAndOfSt4Mt22d+0x42>
xor    %eax,%eax
cmpq   $0x0,-0x18(%rbp)
mov    %al,-0x35(%rbp)
je     1172 <convertIndex2IdSegAndOfSt4Mt22d+0x42>
cmpq   $0x0,-0x20(%rbp)
setne  %al
mov    %al,-0x35(%rbp)
mov    -0x35(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <getUsedNumDatMt22d@plt>
mov    %eax,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x34(%rbp)
cmpl   $0x1,-0x24(%rbp)
jne    1255 <convertIndex2IdSegAndOfSt4Mt22d+0x125>
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jae    121c <convertIndex2IdSegAndOfSt4Mt22d+0xec>
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%esi
call   1050 <getUsedOffsetNumDatMt22d@plt>
mov    %eax,-0x30(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x30(%rbp),%eax
jae    1200 <convertIndex2IdSegAndOfSt4Mt22d+0xd0>
mov    -0x28(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x34(%rbp),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x28(%rbp)
movl   $0x1,-0x24(%rbp)
jmp    1209 <convertIndex2IdSegAndOfSt4Mt22d+0xd9>
mov    -0x34(%rbp),%eax
sub    -0x30(%rbp),%eax
mov    %eax,-0x34(%rbp)
jmp    120e <convertIndex2IdSegAndOfSt4Mt22d+0xde>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11b5 <convertIndex2IdSegAndOfSt4Mt22d+0x85>
cmpl   $0x0,-0x24(%rbp)
jne    124b <convertIndex2IdSegAndOfSt4Mt22d+0x11b>
mov    -0xc(%rbp),%esi
mov    -0x34(%rbp),%edx
lea    0xdcd(%rip),%rdi
mov    $0x446,%ecx
lea    0xe13(%rip),%r8
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1250 <convertIndex2IdSegAndOfSt4Mt22d+0x120>
jmp    1250 <convertIndex2IdSegAndOfSt4Mt22d+0x120>
jmp    127e <convertIndex2IdSegAndOfSt4Mt22d+0x14e>
mov    -0x8(%rbp),%rax
mov    %eax,%esi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
lea    0xe9c(%rip),%rdi
mov    $0x44f,%r8d
lea    0xddb(%rip),%r9
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<convertIndex2IdSegAndOfSt4Mt22d>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rcx,0x8(%rsp)
mov    %rdx,%r12
mov    %esi,%ebp
mov    %rdi,%r13
call   1040 <getUsedNumDatMt22d@plt>
test   %r13,%r13
je     11b0 <convertIndex2IdSegAndOfSt4Mt22d+0x80>
test   %r12,%r12
je     11b0 <convertIndex2IdSegAndOfSt4Mt22d+0x80>
cmpq   $0x0,0x8(%rsp)
je     11b0 <convertIndex2IdSegAndOfSt4Mt22d+0x80>
mov    %eax,%r14d
mov    %ebp,%ebx
test   %eax,%eax
je     11ea <convertIndex2IdSegAndOfSt4Mt22d+0xba>
xor    %r15d,%r15d
mov    %ebp,0x14(%rsp)
mov    %ebp,%ebx
xor    %ebp,%ebp
jmp    118a <convertIndex2IdSegAndOfSt4Mt22d+0x5a>
nopl   0x0(%rax,%rax,1)
mov    %ecx,%ebx
add    $0x1,%ebp
cmp    %r14d,%ebp
jae    11db <convertIndex2IdSegAndOfSt4Mt22d+0xab>
mov    %r13,%rdi
mov    %ebp,%esi
call   1050 <getUsedOffsetNumDatMt22d@plt>
mov    %ebx,%ecx
sub    %eax,%ecx
jae    1180 <convertIndex2IdSegAndOfSt4Mt22d+0x50>
mov    %ebp,(%r12)
mov    0x8(%rsp),%rax
mov    %ebx,(%rax)
mov    $0x1,%r15d
mov    %r14d,%ebp
jmp    1182 <convertIndex2IdSegAndOfSt4Mt22d+0x52>
lea    0xf4f(%rip),%rdi
lea    0xe94(%rip),%r9
xor    %r14d,%r14d
mov    %r13d,%esi
mov    %r12,%rdx
mov    0x8(%rsp),%rcx
mov    $0x44f,%r8d
xor    %eax,%eax
call   1030 <printf@plt>
jmp    120b <convertIndex2IdSegAndOfSt4Mt22d+0xdb>
mov    $0x1,%r14d
test   %r15d,%r15d
mov    0x14(%rsp),%ebp
jne    120b <convertIndex2IdSegAndOfSt4Mt22d+0xdb>
lea    0xe0f(%rip),%rdi
lea    0xe5a(%rip),%r8
xor    %r14d,%r14d
mov    %ebp,%esi
mov    %ebx,%edx
mov    $0x446,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r14d,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.mat2_2d = type { i32 }
@.str = [82 x i8] c"Error(1) in convertIndex2IdSegAndOfSt4Mt22d, the id(%u) exceed:%u, ln:%d,File:%s\0A\00"
@.str.1 = [180 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/Chalearm/MachineLearning-/refs/heads/master/mProject/library_jui/dataStruct/src/simMat2.c\00"
@.str.2 = [89 x i8] c"Error(0) in convertIndex2IdSegAndOfSt4Mt22d, obj:%p, idSeg:%p,Offset:%p ,ln:%d, file:%s\0A\00"
define i32 @convertIndex2IdSegAndOfSt4Mt22d(%struct.mat2_2d* %0, i32 %1, i32* %2, i32* %3) {
%5 = alloca %struct.mat2_2d*
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store %struct.mat2_2d* %0, %struct.mat2_2d** %5
store i32 %1, i32* %6
store i32* %2, i32** %7
store i32* %3, i32** %8
%14 = load %struct.mat2_2d*, %struct.mat2_2d** %5
%15 = icmp ne %struct.mat2_2d* %14, null
br i1 %15, label %16, label %22
16: ; preds = %4
%17 = load i32*, i32** %7
%18 = icmp ne i32* %17, null
br i1 %18, label %19, label %22
19: ; preds = %16
%20 = load i32*, i32** %8
%21 = icmp ne i32* %20, null
br label %22
22: ; preds = %19, %16, %4
%23 = phi i1 [ false, %16 ], [ false, %4 ], [ %21, %19 ]
%24 = zext i1 %23 to i32
store i32 %24, i32* %9
store i32 0, i32* %10
%25 = load %struct.mat2_2d*, %struct.mat2_2d** %5
%26 = call i32 @getUsedNumDatMt22d(%struct.mat2_2d* %25)
store i32 %26, i32* %11
store i32 0, i32* %12
%27 = load i32, i32* %6
store i32 %27, i32* %13
%28 = load i32, i32* %9
%29 = icmp eq i32 %28, 1
br i1 %29, label %30, label %65
30: ; preds = %22
store i32 0, i32* %9
store i32 0, i32* %10
br label %31
31: ; preds = %53, %30
%32 = load i32, i32* %10
%33 = load i32, i32* %11
%34 = icmp ult i32 %32, %33
br i1 %34, label %35, label %56
35: ; preds = %31
%36 = load %struct.mat2_2d*, %struct.mat2_2d** %5
%37 = load i32, i32* %10
%38 = call i32 @getUsedOffsetNumDatMt22d(%struct.mat2_2d* %36, i32 %37)
store i32 %38, i32* %12
%39 = load i32, i32* %13
%40 = load i32, i32* %12
%41 = icmp ult i32 %39, %40
br i1 %41, label %42, label %48
42: ; preds = %35
%43 = load i32, i32* %10
%44 = load i32*, i32** %7
store i32 %43, i32* %44
%45 = load i32, i32* %13
%46 = load i32*, i32** %8
store i32 %45, i32* %46
%47 = load i32, i32* %11
store i32 %47, i32* %10
store i32 1, i32* %9
br label %52
48: ; preds = %35
%49 = load i32, i32* %13
%50 = load i32, i32* %12
%51 = sub i32 %49, %50
store i32 %51, i32* %13
br label %52
52: ; preds = %48, %42
br label %53
53: ; preds = %52
%54 = load i32, i32* %10
%55 = add i32 %54, 1
store i32 %55, i32* %10
br label %31
56: ; preds = %31
%57 = load i32, i32* %9
%58 = icmp eq i32 %57, 0
br i1 %58, label %59, label %63
59: ; preds = %56
%60 = load i32, i32* %6
%61 = load i32, i32* %13
%62 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([82 x i8], [82 x i8]* @.str, i64 0, i64 0), i32 %60, i32 %61, i32 1094, i8* getelementptr inbounds ([180 x i8], [180 x i8]* @.str.1, i64 0, i64 0))
br label %64
63: ; preds = %56
br label %64
64: ; preds = %63, %59
br label %71
65: ; preds = %22
%66 = load %struct.mat2_2d*, %struct.mat2_2d** %5
%67 = ptrtoint %struct.mat2_2d* %66 to i32
%68 = load i32*, i32** %7
%69 = load i32*, i32** %8
%70 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([89 x i8], [89 x i8]* @.str.2, i64 0, i64 0), i32 %67, i32* %68, i32* %69, i32 1103, i8* getelementptr inbounds ([180 x i8], [180 x i8]* @.str.1, i64 0, i64 0))
br label %71
71: ; preds = %65, %64
%72 = load i32, i32* %9
ret i32 %72
}

LLVM IR (-O2):
%struct.mat2_2d = type { i32 }
@.str = [82 x i8] c"Error(1) in convertIndex2IdSegAndOfSt4Mt22d, the id(%u) exceed:%u, ln:%d,File:%s\0A\00"
@.str.1 = [180 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/Chalearm/MachineLearning-/refs/heads/master/mProject/library_jui/dataStruct/src/simMat2.c\00"
@.str.2 = [89 x i8] c"Error(0) in convertIndex2IdSegAndOfSt4Mt22d, obj:%p, idSeg:%p,Offset:%p ,ln:%d, file:%s\0A\00"
define i32 @convertIndex2IdSegAndOfSt4Mt22d(%struct.mat2_2d* %0, i32 %1, i32* %2, i32* %3) {
%5 = icmp ne %struct.mat2_2d* %0, null
%6 = icmp ne i32* %2, null
%7 = and i1 %5, %6
%8 = icmp ne i32* %3, null
%9 = and i1 %7, %8
%10 = tail call i32 @getUsedNumDatMt22d(%struct.mat2_2d* %0)
br i1 %9, label %11, label %33
11: ; preds = %4
%12 = icmp eq i32 %10, 0
br i1 %12, label %30, label %13
13: ; preds = %11, %22
%14 = phi i32 [ %25, %22 ], [ %1, %11 ]
%15 = phi i32 [ %24, %22 ], [ 0, %11 ]
%16 = phi i32 [ %26, %22 ], [ 0, %11 ]
%17 = tail call i32 @getUsedOffsetNumDatMt22d(%struct.mat2_2d* %0, i32 %16)
%18 = icmp ult i32 %14, %17
br i1 %18, label %19, label %20
19: ; preds = %13
store i32 %16, i32* %2
store i32 %14, i32* %3
br label %22
20: ; preds = %13
%21 = sub i32 %14, %17
br label %22
22: ; preds = %19, %20
%23 = phi i32 [ %10, %19 ], [ %16, %20 ]
%24 = phi i32 [ 1, %19 ], [ %15, %20 ]
%25 = phi i32 [ %14, %19 ], [ %21, %20 ]
%26 = add i32 %23, 1
%27 = icmp ult i32 %26, %10
br i1 %27, label %13, label %28
28: ; preds = %22
%29 = icmp eq i32 %24, 0
br i1 %29, label %30, label %37
30: ; preds = %11, %28
%31 = phi i32 [ %25, %28 ], [ %1, %11 ]
%32 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([82 x i8], [82 x i8]* @.str, i64 0, i64 0), i32 %1, i32 %31, i32 1094, i8* getelementptr inbounds ([180 x i8], [180 x i8]* @.str.1, i64 0, i64 0))
br label %37
33: ; preds = %4
%34 = ptrtoint %struct.mat2_2d* %0 to i64
%35 = trunc i64 %34 to i32
%36 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([89 x i8], [89 x i8]* @.str.2, i64 0, i64 0), i32 %35, i32* %2, i32* %3, i32 1103, i8* getelementptr inbounds ([180 x i8], [180 x i8]* @.str.1, i64 0, i64 0))
br label %37
37: ; preds = %30, %28, %33
%38 = phi i32 [ 0, %30 ], [ 1, %28 ], [ 0, %33 ]
ret i32 %38
}